Norwegian Parcel Mail

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

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

    Install

    npm i cache-manager-memcached-store

    DownloadsWeekly Downloads

    7,527

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    21.4 kB

    Total Files

    10

    Last publish

    Collaborators

    • theo.gravity
    • romon2002