Bridging state across a plugin restart

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Tue Feb 26, 2013 1:22 am
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Bridging state across a plugin restart

I have a plugin with expensive state. When it gets restarted (or perhaps crashes :-), I want to save and then restore that state. This is not persistent data - if we don't restart immediately, it should be ditched and reconstructed. How do I go about this? I can easily make a Dict with all the data, but where do I stuff it, and how do I retrieve it?

Cheers
-- perry

Posted on
Tue Feb 26, 2013 8:20 am
matt (support) offline
Site Admin
User avatar
Posts: 21426
Joined: Jan 27, 2003
Location: Texas

Re: Bridging state across a plugin restart

I'm not quite sure I understand. It sounds like you do want it to be persistent data, unless the time interval between the stop/crash and next start is > N. In that case you'll want to store the dict in the pluginProps along with a timestamp so you can know if the data should be used or dumped on next launch. Alternatively you can always create/manage your own cache file I suppose.

Image

Posted on
Tue Feb 26, 2013 9:59 am
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: Bridging state across a plugin restart

Of course I could use the PluginProps and a timestamp. But those get written to a preference file, and I just feel a bit dirty using a persistent store for what amounts to transient data. I was hoping to find some corner of Indigo's memory to stash that data. (Indigo's device state gets wiped across a plugin restart, right?)

Cheers
-- perry

Posted on
Tue Feb 26, 2013 10:08 am
matt (support) offline
Site Admin
User avatar
Posts: 21426
Joined: Jan 27, 2003
Location: Texas

Re: Bridging state across a plugin restart

There isn't any plugin API access to an Indigo Server runtime dict where plugins can stash semi-persistent (or semi-transient, I guess, if you are a glass-half-empty pessimist) data.

States are maintained, but they can only hold atomic values (no dicts/lists) and they also show up in the trigger/conditional/control page UI. And they might get saved to the database file before the plugin can clear the data. Since the data isn't really a plugin preference (and it might be large?), I'd recommend just writing it to a temp file.

Image

Posted on
Tue Feb 26, 2013 10:16 am
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: Bridging state across a plugin restart

I'd recommend just writing it to a temp file

I'll do that.

Cheers
-- perry

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests