Page 1 of 1
lazy write
Posted: 15 Feb 2022 20:13
by piet66
Hello,
can anybody please provide some information about the new lazy write method? I've not yet found anything. What's the meaning of the additional parameter (true, immediate) in saveObject?
Re: lazy write
Posted: 15 Feb 2022 22:47
by PoltoS
saveObject = function(name, object, immediate)
immediate can be:
0 or true to write right now
>0 to defer it to N seconds
undefined (missing) to use the default defer time of 5 minutes
Re: lazy write
Posted: 16 Feb 2022 15:07
by piet66
That means, another application can read this data not before the defer time is over?
Is the file stored with the same Linux process as the module instance or with a different process?
Re: lazy write
Posted: 16 Feb 2022 22:52
by PoltoS
Correct. The data is not written to the filesystem before the defer time. This reduces write cycles and improved the SD card performance.
Of course the same pricess is doing save the data to the filesystem, just a bit later.
Re: lazy write
Posted: 17 Feb 2022 12:13
by piet66
I'm sorry to be so insistent. But you will know that I'm using saveObject in my MxChartJS module. And of course I want to do that as little stressing as possible.
This reduces write cycles and improved the SD card performance.
This sentence I haven't understood. Why does it reduce the write cycles, if you only do a break before execution? This doesn't combine the various write accesses?
Re: lazy write
Posted: 17 Feb 2022 13:38
by PoltoS
We are keeping the object in memory instead of writing to the SD. After 5 minutes we will save it to the memory. So all intermediate saveObject will be skipped.