node.js - Remembering a value -
I have a nodes application that is applicable to it. This app has a counter variable.
Every time a certain event occurs, this counter variable has increased.
Now, I do not want to lose the value of this counter. This is the situation that the NodJS app is restarted, I want the value of this counter set before it was restarted.
In other words, I should remember a value
Is there an add-on or is it possible to set environment variables or something in it?
You have to save the price somewhere else. You can save it in a file or in a database. Given that your app is not looking super complex, a file probably makes the most sense. Use found in node core.
var fs = need ('fs'); // save the counter value to the file. Function Saving Counts (calculation) {fs.writeFileSync ('counter.dat', counting); } // Recover counter values from file function getCount () {return parseInt (fs.readFileSync ('counter.dat')); }
If you want to go with a simple name / price database then have a look at them.
Comments
Post a Comment