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
SetValue persistency [#14995]
Moderators: jiri, drakinite, Addon Administrators
Re: SetValue 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 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?
Different, INI stores rather just values that are same for MM4 and MM5 (for backward compatibility)
MM5 values are stored in persistent.json
Yes, you (as the creator) are responsible for the housekeeping.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?
persistent.json
Re: SetValue persistency
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.
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
In next build we will add app.removeValue method.
How to make a debuglog - step 4b: viewtopic.php?f=30&t=86643
Re: SetValue persistency
Awesome, thanks a lot!