Where in the docs does it explain how to specify that a Write operation for roRegistry should be transient, as described in the component reference manual? Other than this paragraph below, the word “transient” does not appear anywhere else in the doc, and I cannot find how to specify a write to be transient as described here:
“The Registry also supports the use of a special “Transient” registry section. This registry section allows the application to store attributes that have the lifetime of a single boot. Within a specific boot session, these values will be persistent to the application and stored as any other registry value. Whenever the user reboots the Roku Streaming Player, the “Transient” registry section is removed and the values no longer persist. This technique is useful for caching data to minimize network access, yet still ensuring that this data is always fresh after a system reboot.”
I think (I’m not near a Roku to test and verify right now) you just use the string “Transient” when creating the roRegistrySection object, e.g.:
CreateObject(“roRegistrySection”, “Transient”)
Has this changed? Because I was able to store a much larger amount of data than 16KB and it persisted over channel sessions but was lost on reboot. I never specified “transient” as the section name, but maybe it defaulted to that when trying the flush() since it saw the data amount was too big for the regular registry?
If you didn’t use “transient” as section name, then you are experiencing something else - something that is a bug, omission, undocumented - and as such subject to change, so don’t rely on it in your code. Same goes on being able to store >16KB in the registry because of the gzip implementation. I say don’t rely on that, be prudent in your choice.
On a side note, amusing thought - formatJSON() will likely give you a close estimate of how big the registry storage (keys and values) will be pre-compression.
It returns False, but definitely behaves like Transient. I don’t know what the upper limit is (Roku memory?). Sounds like this is definitely a bug.
In console I tested: sec = CreateObject(“roRegistrySection”, “test”) FOR i = 1 to 50000: sec.Write(i.ToStr(), i.ToStr()): END FOR ? sec.Flush()
Then I exited channel (Home), opened another channel, exited it, reloaded channel, and entered in console: sec = CreateObject(“roRegistrySection”, “test”) FOR i = 1 to 50010: ? i ", " sec.Read(i.ToStr()): END FOR
I’ve only tested on my Roku HD 2500, Software 6.2 build 3471
So the Flush is telling you that it failed to write the data to storage. The question is what is the best behavior at that point? Currently it apparently just leaves the data in memory and it is still accessible until the next reboot. An alternative would be to discard all the data in memory when a Flush fails. The latter is probably better although I can imagine some cases where the developer might prefer the current behavior. I’ll file a bug and we’ll review it, but if that’s the behavior you want right now, you may want to just Delete all your registry sections when Flush fails.