So lets say I have this global variable foo, which while my server is running I can access it. What I want to be possible is if my server crashes it will first initially try to recover foo, then continue to do server stuff. I want to know the best way possible to do such a thing. Here are the ways I can think of doing this.
1, Whenever foo is updated, (which not frequently), I will write to a file a marshalized foo, and when my server crashes it will eval the content’s of the file to be foo.
2, Use a light database such as sqlite to store foo,
Come to think about it both these ideas are really closely related, but is there a referred solution given that foo is at any point going to be 10kBytes.
I would store the var in redis. This allows what you want and provides scalability.
Node redis module: https://github.com/mranney/node_redis
Hands on: http://howtonode.org/node-redis-fun