1.0.4-4 • Published 12 years ago
cache-back v1.0.4-4
node-cache-back
node-cache-back is a datastore adaptable node cache library
Installation
npm install --save cache-backAPI
Initialize:
var Cacheback = require("cache-back").initialize(); // in-memory by defaultwhich is the same as:
var Cacheback = require("cache-back").initialize('memory'); Use Redis as datastore:
var Cacheback = require("cache-back").initialize('redis', {
host: '127.0.0.1', // default
port: 6379 // default
}); Use MongoDB as datastore:
var Cacheback = require("cache-back").initialize('mongodb', {
host: '127.0.0.1', // default
port: 27017, // default
database: 'cacheback' // default
}); Methods
Get by cache key:
Cacheback.get('key', function (err, data) { ... })Set by cache key
Cacheback.set('key', data, '10 minutes', function (err, cached) { ... });Expire a key:
Cacheback.expire('key', function (err, removed) { ... });See if key exists and valid
Cacheback.exists('key', function (err, exists) { ... });Count cached keys
Cacheback.count(function (err, count) { ... });Clean up expired keys
Cacheback.clean(function (err, removedCount) { ... });Expire all cache
Cacheback.expireAll(function (err) { ... });Test
npm testContribute
- Fork it
- Pork it
- Issue a pull request
Changelog
V 1.0.4
- 1.0.4-4 Updated documentation
- 1.0.4-3 All callbacks are optional
- 1.0.4-2 Redis, MongoDB and In-Memory cache support, improved performance, test suite
License
MIT