1.0.4-4 • Published 11 years ago

cache-back v1.0.4-4

Weekly downloads
8
License
MIT
Repository
github
Last release
11 years ago

node-cache-back

node-cache-back is a datastore adaptable node cache library

Installation

npm install --save cache-back

API

Initialize:

var Cacheback = require("cache-back").initialize(); // in-memory by default

which 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 test

Contribute

  1. Fork it
  2. Pork it
  3. 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

1.0.4-4

11 years ago

1.0.4-3

11 years ago

1.0.4-2

11 years ago

1.0.4-1

11 years ago

1.0.4

11 years ago