poseidon-memcached

A future wrapper around the Node Memcached driver using Poseidon.

npm install poseidon-memcached
12 downloads in the last month

Poseidon Memcached

Poseidon Memcached provides a promise layer around the node memcached module with the help of the Poseidon library.

Install

To get started simply run

npm install poseidon-memcached

Introduction

A basic example of performing serveral operations on a cache which would normally result in callback hell is shown below.

{Driver, Cache} = require '../index'

Driver.configure('default', { servers: 'localhost:11212' })
cache = new Cache('default')

cache.add('test', { foo: 'bar' }, 0)
.then ->
  console.log 'object added'
  cache.get('test')
.then (obj) ->
  console.log 'object retrieved', obj
  cache.del('test')
.then ->
  console.log 'object deleted'
  cache.add('test', {foo: 'bar returns' }, 0)
.then ->
  cache.add('test2', {bar: 'foo'}, 0)
.then ->
  console.log 'new objects added'
  cache.get(['test', 'test2'])
.then (objs) ->
  console.log 'objects retrieved', objs
.fail (err) ->
  console.error err
.finally ->
  console.log 'connection closed'
  cache.end()
.done()

API

All functions of the original module are available

  • get
  • gets
  • getMulti
  • add
  • set
  • del
  • cas
  • flush

License

The MIT License

Copyright(c) 2013-2014, Playlyfe Technologies, developers@playlyfe.com, http://dev.playlyfe.com/

npm loves you