1.0.1 • Published 8 years ago
openam-agent-cache-redis v1.0.1
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
- RedisCache ⇐ Cache
- new RedisCache([options])
- instance
- .get(key) ⇒ Promise
- .put(key, value) ⇒ Promise
- .remove(key) ⇒ Promise
- .quit() ⇒ Promise
- static
- .PREFIX : string
new RedisCache(options)
Cache implementation for redis
Param | Type | Default | Description |
---|---|---|---|
options | object | Options | |
options.url | string | "redis://localhost/6379" | redis URL |
options.expireAfterSeconds | number | 60 | Expiration time in seconds |
options.redis | * | undefined | Redis 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
Param | Type |
---|---|
key | string |
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
Param | Type |
---|---|
key | string |
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
Param | Type |
---|---|
key | string |
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