0.7.1 • Published 7 years ago

node-memcached-client v0.7.1

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

node-memcached-client

Client library of Memcached for nodejs using ES6 promisified methods

NPM Build Status Coverage Status Code Climate

Features

  • Implemented ES6 features
  • Any store and get operation returns Promise
  • Auto reconnection if memcahed server is down unexpectedly
  • Connection pooling per host, scaling

Installation

$ npm install node-memcached-client

Usage

Callback style connect:

const Memcached = require('node-memcached-client');
const client = new Memcached({
  host: 'localhost',
  port: 11211
});

client.on('connect', () => {
  client.set('foo', 'bar', false, 100)
  .then(() => {
      return client.get('foo');
  })
  .then(foo => {
    console.log(foo); // bar
    client.close();
  });
});
client.connect();

Promise style connect:

const Memcached = require('node-memcached-client');
const client = new Memcached({
  host: 'localhost',
  port: 11211
});

client.connect()
.then(c => {
  c.set('foo', 'bar', false, 100)
  .then(() => c.get('foo'))
  .then(foo => {
    console.log(foo); // bar
    c.close();
  });
});

Client Options

nametypedefault valuedescription
hoststring'localhost'Memcached server to connect
portNumber11211Memcached port to connect
autoreconnectBooleanfalseClient tries to reconnect
commandTimeoutNumber2000Duration times of command timeout (msec)
reconnectDurationNumber2000Duration times of reconnect (msec)
maxRetryConnectCountNumer10Retry times to reconnect

Connection Pooling Settings

Pooling configuration enable to change by environment variables:

nametypedefault valuedescription
MEMCACHED_CLIENT_MAX_POOL_SIZENumber1Connection pooling size per host:port signature
MEMCACHED_CLIENT_SCALE_THRESHOLD_SIZENumber100Threshold to increase client connection
0.7.1

7 years ago

0.6.8

7 years ago

0.6.7

7 years ago

0.6.6

7 years ago

0.6.5

7 years ago

0.6.4

7 years ago

0.6.3

7 years ago

0.6.2

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago