SetValue persistency

To discuss development of addons / skins / customization of MediaMonkey.

Moderator: jiri

TIV73
Posts: 71
Joined: Sat Nov 12, 2011 1:31 pm

SetValue persistency

Post 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

Ludek
Posts: 2522
Joined: Fri Mar 09, 2007 9:00 am

Re: SetValue persistency

Post 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

TIV73
Posts: 71
Joined: Sat Nov 12, 2011 1:31 pm

Re: SetValue persistency

Post 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.

PetrCBR
Posts: 1478
Joined: Tue Mar 07, 2006 5:31 pm
Location: Czech
Contact:

Re: SetValue persistency

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

In next build we will add app.removeValue method.

TIV73
Posts: 71
Joined: Sat Nov 12, 2011 1:31 pm

Re: SetValue persistency

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

Awesome, thanks a lot!

Post Reply