How do I store data to be used for all the clients in my server? (like the messages of a chat)
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- google-drive can't get push notifications
- How to reimport module with ES6 import
- Why is `node.js` dying when called from inside pyt
- How to verify laravel passport api token in node /
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
- Get file created date in node
I wrote Bx for this purpose; it gives you a simple in-memory cache with:
Although I'm plugging my own repository here, I can assure you it works well and it's been used in production at my own company, Onshape for over a year without issues. At the end of the day it's a pretty simple tool; not much to mess up here.
However, if you're storing data that's meant to be permanent you're going to want a database such as MongoDB (w/ Mongoose), MySQL, etc. rather than a cache like Bx or Redis.
If you want more features have a look at redis-node-client
The server that node.js allows you to build, is an application server, which means that state is preserved, between request, on the server side. The following snippet demonstrates this:
node-cache package is currently the best for key value store and it allows synchronous as well as async storage/retrieval/deletion of keys.
npm link
Or use a native node storage mechanism (written in node.js)
http://github.com/felixge/node-dirty