cache-manager-memcached-store
v6.0.1
Published
memcached impl for cache-manager
Downloads
19,014
Readme
Node Cache Manager store for Memcached
The Memcached store for the node-cache-manager
Module can use different compatible memcache clients as the underlying memcache library:
Installation
Install one of the memcached clients from above and cache-manager-memcached-store
npm i memcache-pp --save
npm i cache-manager-memcached-store --save
Acknowledgements
Some of the project scaffolding and test/comments are lifted from node-cache-manager-redis
Till version 3.0.0 cache-manager-memcached-store
uses memcache-plus
as the underlying memcached library.
Newer versions allow to choose any compatible library by passing it's constructor in a driver option. See example below.
Usage examples
const Memcache = require('memcache-pp')
const cacheManager = require('cache-manager')
const memcachedStore = require('cache-manager-memcached-store')
const memcachedCache = cacheManager.caching({
store: memcachedStore,
driver: Memcache,
// http://memcache-plus.com/initialization.html - see options
options: {
hosts: ['127.0.0.1:11211']
}
})
const ttl = 30
// Compression must be manually set - see memcached-plus documentation
// The key must always be a string
// http://memcache-plus.com/set.html
memcachedCache.set('foo', 'bar', ttl, function(err) {
if (err) {
throw err
}
// http://memcache-plus.com/get.html
memcachedCache.get('foo', function(err, result) {
console.log(result)
// >> 'bar'
memcachedCache.del('foo', function(err) {})
})
})