Page 1 of 1

SetValue persistency [#14995]

Posted: Sat Jul 14, 2018 12:38 am
by TIV73
Hi there,
I recently saw the SetValue/GetValue methods in the api documentation which makes it possible store and retrieve persistent data. Now I'm curios about how the methods are meant to be used and have a couple of questions.

What does 'persistent' mean in this context? Like, is an object that's stored via SetValue guaranteed to be persistent regardless of the lifecycle of the application (restart/version upgrades and patches/re-installation/etc.) or is it just a cache for often accessed values that's persistent between sessions but has no long time persistency?

How does it compare to storing values in mm.ini via app.settings.getjson/setjson? Is it meant to replace writing custom settings to the ini file or are there different use cases?

Who's responsible for data housekeeping? Let's say I store a temporary value which, after some time, is not needed anymore. Is there something like a garbage collection that detects stale data and cleans it up after a while or am I responsible for removing these values myself? If so, how do I do it?

Where is the data stored?

BR,
Michael

Re: SetValue persistency

Posted: Mon Jul 23, 2018 6:48 am
by Ludek
TIV73 wrote: Sat Jul 14, 2018 12:38 am What does 'persistent' mean in this context? Like, is an object that's stored via SetValue guaranteed to be persistent regardless of the lifecycle of the application (restart/version upgrades and patches/re-installation/etc.) or is it just a cache for often accessed values that's persistent between sessions but has no long time persistency?
You can use them for both, the values are stored in app memory and flushed (stored) to persistent.json file while MM5 is not running.

TIV73 wrote: Sat Jul 14, 2018 12:38 am How does it compare to storing values in mm.ini via app.settings.getjson/setjson? Is it meant to replace writing custom settings to the ini file or are there different use cases?
Different, INI stores rather just values that are same for MM4 and MM5 (for backward compatibility)
MM5 values are stored in persistent.json
TIV73 wrote: Sat Jul 14, 2018 12:38 am Who's responsible for data housekeeping? Let's say I store a temporary value which, after some time, is not needed anymore. Is there something like a garbage collection that detects stale data and cleans it up after a while or am I responsible for removing these values myself? If so, how do I do it?
Yes, you (as the creator) are responsible for the housekeeping.
TIV73 wrote: Sat Jul 14, 2018 12:38 am Where is the data stored?
persistent.json

Re: SetValue persistency

Posted: Wed Jul 25, 2018 3:49 pm
by TIV73
Awesome, thanks for sharing that information!

One more thing, is there a function to remove a value once it was set (without manually removing from persisent.json)? I couldn't find a dedicated remove/delete/unset value function.
Also, trying passing null to setValue causes an exception. Not sure if that's an actual bug or should be considered a user error for inproper handling of the function.

Re: SetValue persistency

Posted: Mon Jul 30, 2018 7:18 am
by PetrCBR
In next build we will add app.removeValue method.

Re: SetValue persistency

Posted: Mon Jul 30, 2018 12:11 pm
by TIV73
Awesome, thanks a lot!