contextStorage questions

I have 3 rpi's running node-red 0.2.6 .. one of them doesn't have the // Context Storage section in the system.js file so I tried updating to 0.2.7 .. it seam's to keep the same system.js file even though I updated, so the question is can I just paste in the missing lines from one of the other pi's system.js files ?

Also secondary question, I have one pi working fine with contextStorage if I reboot, the vars I stored in my
"localfilesystem" are persistent, I can see /home/pi/.node-red/context but that folder is empty, shouldn't I see some file in there that contains my stored vars ?

can I just paste in the missing lines from one of the other pi's system.js files

Yes. The settings.js will only be created if it doesn't exist. So, in your case, you need to add the new context settings to your existing settings.js file.

I can see /home/pi/.node-red/context but that folder is empty, shouldn't I see some file in there that contains my stored vars ?

again yes it should be there. In /home/pi/.node-red do you see your flow files?

Yes I see my flow files as before but when I added into my setting.js file the following

contextStorage: {
	storeInFile: { module: "localfilesystem"},
		default    : { module: "memory" }
},

After rebooting I see it made a directory called 'context', after I set up some test like
flow.set('Usage_count',msg.payload,'localfilesystem'); etc etc tested it was working and when rebooted Usage_count refreshed its values from ,'localfilesystem' all as expected, however the context directory is still empty, I expected something to be in there, not ?


Oh think I may have found problem flow.set('Usage_count',msg.payload,'localfilesystem') should be flow.set('Usage_count',msg.payload,'storeInFile') checking if it works !

It might be helpful to read this thread: A guide to understanding 'Persistent Context'

You can have the 'filesystem' be the default so you don't need to specify it.

OK that was the problem and now it works and I see a file in the context folder containing the persistent data
Actually I was already following that guide you mentioned, I just made that simple error.

Regarding ' You can have the 'filesystem' be the default so you don't need to specify it.' wouldn't that mean every flow.set I have used in every tab would be saved to file ... that would be hundreds of entry's and I guess slow every thing down, in reality I only want specific data to be persistent but thank you very much for your assistance

You can add the flushInterval property to your file contextStorage item in settings.js to specify how often you want it to write to disk, by default this is 30 seconds. It doesn't immediately go to disk, so it's quite fast.

Hundreds of entries?? What are you storing? have you thought about consolidating

Sorry I don't understand what you mean .. consolidating
The tab / flow I am currently developing has 56 flow.set('bla bla , listed below, I currently only need 4 of these to be persistent.
However I have another 42 tabs I am assuming that if I made 'filesystem' to be the default then every flow.set('bla bla would be saved to file instead of memory, surly that would slow things up.

I do have one question though ... say I do flow.set('Leaf_this_month',0,'storeInFile'); that gets saved to file now say I decide to change that to say flow.set('Leaf_current_month',0,'storeInFile'); thay are both in the file store so how do I delete the one I no longer want 'Leaf_this_month' ?

Do I have to use the change node to delete the whole context store or can i delete a specific items ?

Leaf_countstoreInFile 14459

You can set a value to undefined and it will be deleted from the store.

you can store an object. Here is an example function (default is store in file)

var book ={};
book.author = "Dr. Suess";
book.title = "Mr. Brown can moo, can you?";
book.TimesBorrowed = 27; 
book.WhenDue=Date.now();

flow.set('book',book);
var lent = flow.get('book');
lent.TimesBorrowed++
flow.set('book',lent);
return msg;

I don't know if your data can be grouped, this was just a suggestion.

Yes it works thanks...
flow.set("Usage_this_month",undefined,'storeInFile');
refresh browser