cache-manager-memcached-store
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/cache-manager-memcached-store package

6.0.1 • Public • Published

Node Cache Manager store for Memcached

js-standard-style Build Status npm version

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) {})
  })
})

Package Sidebar

Install

npm i cache-manager-memcached-store

Weekly Downloads

4,839

Version

6.0.1

License

MIT

Unpacked Size

28.6 kB

Total Files

10

Last publish

Collaborators

  • theo.gravity
  • romon2002