1.0.2 • Published 7 years ago

@megadoomer/membrane v1.0.2

Weekly downloads
1
License
MIT
Repository
bitbucket
Last release
7 years ago

Membrane

The multi caching package

Configuration

Configuration consists of an object found at the caches key. Each key in the object will be considered a unique cache. Each Cache will be available as a property on the membrane module or as a callable from the package itself. Their must be one and only one cache named default which will be the primary cache when no cache is specified.

the following configuration would set up two caches, the default, a redis cache, and a testing cache, an in memory cache

config
{
  "caches":{
    "default":{
      "backend":"redis"
    }
    ,"testing":{
      "backend":"memory",
    }
  }
}
usage
var cache = require( 'membrane' );

// using the redis cache
cache.set('foo', 'bar')

// using the dummy cache explicitly
cache.dummy.set('foo', 'bar')

// using the dumy cache though the cache callable
cache( 'dummy' )
  .set('foo','bar' )

Caches

optionsdefaulttypedescription
backenddummystringone of the predefined backends, redis, memcached, memory, dummy, or a fully qualified path to a module which exports a class which implements the cache interface
location""string / objecta connection string or object containing host, port, and auth creds if required
timeout30000numberthe time to live in ms.
prefix"membrane"stringa keyspace name-space to separate specific sets of keys
optionsnullobjectdriver specific options to be passed to the connection
{
  "caches":{
    "default":{
      "backend":"memcache",
      "location":{
        "host":"0.0.0.0",
        "port":11211
      }
    }
    ,"counters":{
      "backend":"redis"
      ,"location":"unix://user:abc123@localhost:6379"
      ,options:{
        "return_buffers":false,
        "no_ready_check":true
      }
    }
  }
}

Backends

Dummy

A noop backend to use for testing when a server is not available

Redis

Backend using the redis database driver. Reids support atomic operations for lists, hashes, sets, counters, and transactions

Memcached

Backend using memcached, the low volatile key/value in memory hash table.

1.0.2

7 years ago

1.0.1

7 years ago