save-state
Use your favourite data store like In-Memory cache, MongoDB, Redis and Elastic without worrying about the internal implementations.
NPM https://www.npmjs.com/package/save-state
Installation
npm install save-state
Usage
Example
const Store = ;const client = Store; // register listenerclient; client;
createClient takes optional data store config, with no config passed returns In-Memory Store Client
Examples below
- Mongo Client
const client = Store;
- Redis Client
const client = Store;
- Elasticsearch Client
const client = Store;
set API
set takes JSON document whose key is string and value is a document. Can pass more than one document to be saved at once.
// save documentclient; // save multiple documentsclient; // save multiple documentsclient;
client // throws error
get API
get takes array of strings (keys) to fetch documents from data store.
// retrieve documentclient; // retrieve multiple documentsclient;
remove API
remove takes a string (key) to delete document from data store.
// delete documentclient;
removeAll API
removeAll deletes all document from data store.
// delete all documentsclient;
- Developer notes on local setup