cacheman-redis-promise

1.0.1 • Public • Published

cacheman-redis-primose

Basically an extension of cacheman-redis module that uses promises and is able to disable caching without messing up all code.

Instalation

$ npm install cacheman-redis-promise

Usage

var cache = require('cacheman-redis-promise')({host: '127.0.0.1', port: 6379})

cache.set('some key', 'hello there').then(function(data) {
	console.log(data); // -> 'hello there'
	return cache.get('some key');
}).then(function(data) {
	console.log(data); // -> 'hello there' from cache.get
	return cache.del('some key');
}).then(function() {
	console.log('value deleted');
});

// Or you can use fetch to simplify common cache operations
// (like get, then check and then set if there is no value)

var fn = function() {
	return 'hey there';
	// Or you can also return a promise here
};

// fn will be executed only if there is no value under 'some key' key
// and its result will be put into cache under this key
// But if there was value under the key, it will be returned without executing fn
cache.fetch('some key', fn).then(function(data) {
	console.log(data); // -> 'hey there'
});

Readme

Keywords

Package Sidebar

Install

npm i cacheman-redis-promise

Weekly Downloads

1

Version

1.0.1

License

ISC

Last publish

Collaborators

  • karpov_s
  • staskjs