1.3.0 • Published 7 years ago

mdb-cache v1.3.0

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

Simple mongo db key-value store implementation

Usage

var MongoDBCache = require('mdb-cache');
var mdbCache = new MongoDBCache({
  uri: 'mongodb://127.0.0.1:27017/data-cache-db', //default
  collection: 'mdb-cache', //default
  connectionOptions: {},
  idFeild: '_id' //default, stands for feild name of 'key' in mongodb
});

//return a promise resolve the value, 
//can pass in a function as second parameter that check the vadality of the value,
//and if function return true, value will be deleted, and get promise will resolve null;
mdbCache.get(key, invalid);

//return a promise that indicates successfully 'set' if fulfilled
mdbCache.set(key, value);

//return a promise that indicates successfully 'delete a key-value' if fulfilled
mdbCache.del(key);

//close connection;
mdbCache.close();

// register an error handler
mdbCache.onError(onErrorHandler);
1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

8 years ago

1.0.0

8 years ago