1.0.1 • Published 8 years ago

openam-agent-cache-redis v1.0.1

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

openam-agent-cache-redis

Cache using Redis for the OpenAM Policy Agent for NodeJS

Installation: npm install openam-agent-cache-redis

API Docs

RedisCache ⇐ Cache

Kind: global class
Extends: Cache

new RedisCache(options)

Cache implementation for redis

ParamTypeDefaultDescription
optionsobjectOptions
options.urlstring"redis://localhost/6379"redis URL
options.expireAfterSecondsnumber60Expiration time in seconds
options.redis* | undefinedRedis options (see https://www.npmjs.com/package/redis)

Example

var redisCache = new RedisCache({
  url: 'redis://cache.example.com:6379',
  expireAfterSeconds: 600,
  redis: {
     retry_strategy: function (options) {
         // do stuff
     }
  }
});

redisCache.get(key) ⇒ Promise

Get a single cached item If the entry is not found, reject

Kind: instance method of RedisCache

ParamType
keystring

Example

redisCache.get('foo').then(function (cached) {
  console.log(cached);
}).catch(function (err) {
  console.error(err);
});

redisCache.put(key, value) ⇒ Promise

Store a single cached item (overwrites existing)

Kind: instance method of RedisCache

ParamType
keystring
value*

Example

redisCache.put('foo', {bar: 'baz'}).then(function () {
  console.log('foo saved to cache');
}).catch(function (err) {
  console.error(err);
});

redisCache.remove(key) ⇒ Promise

Remove a single cached item

Kind: instance method of RedisCache

ParamType
keystring

Example

redisCache.remove('foo').then(function () {
  console.log('foo removed from cache');
}).catch(function (err) {
  console.error(err);
});

redisCache.quit() ⇒ Promise

Closes the client connection

Kind: instance method of RedisCache

RedisCache.PREFIX : string

Default prefix for storing keys Value: "node-openam-agent-cache:"

Kind: static property of RedisCache