SetValue persistency [#14995]

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: SetValue persistency [#14995]

Re: SetValue persistency

by TIV73 » Mon Jul 30, 2018 12:11 pm

Awesome, thanks a lot!

Re: SetValue persistency

by PetrCBR » Mon Jul 30, 2018 7:18 am

In next build we will add app.removeValue method.

Re: SetValue persistency

by TIV73 » Wed Jul 25, 2018 3:49 pm

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

by Ludek » Mon Jul 23, 2018 6:48 am

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

SetValue persistency [#14995]

by TIV73 » Sat Jul 14, 2018 12:38 am

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

Top