# node-memcached-client

> Memcached client library for nodejs with ES6 promisified methods

Latest version **0.7.1** (published 2017-06-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-memcached-client
pnpm add node-memcached-client
yarn add node-memcached-client
bun add node-memcached-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.1 |
| Published | 2017-06-28 |
| First published | 2017-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yoshiaki Sugimoto |
| Maintainers | ysugimoto |
| Keywords | nodejs, memcached |

## Links

- npm: https://www.npmjs.com/package/node-memcached-client
- Repository: https://github.com/ysugimoto/node-memcached-client
- Homepage: https://github.com/ysugimoto/node-memcached-client#readme
- Issues: https://github.com/ysugimoto/node-memcached-client/issues
- npm.io page: https://npm.io/package/node-memcached-client

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.7.1 (latest) — 2017-06-28
- 0.6.8 — 2017-03-16
- 0.6.7 — 2017-03-16
- 0.6.6 — 2017-03-16
- 0.6.5 — 2017-03-14
- 0.6.4 — 2017-03-13
- 0.6.3 — 2017-03-13
- 0.6.2 — 2017-03-13
- 0.6.1 — 2017-03-13
- 0.6.0 — 2017-03-13

## README

# node-memcached-client

Client library of Memcached for nodejs using ES6 promisified methods

[![NPM](https://nodei.co/npm/node-memcached-client.png)](https://npmjs.org/package/node-memcached-client)
[![Build Status](https://travis-ci.org/ysugimoto/node-memcached-client.svg?branch=master)](https://travis-ci.org/ysugimoto/node-memcached-client)
[![Coverage Status](https://coveralls.io/repos/github/ysugimoto/node-memcached-client/badge.svg)](https://coveralls.io/github/ysugimoto/node-memcached-client)
[![Code Climate](https://codeclimate.com/github/ysugimoto/node-memcached-client/badges/gpa.svg)](https://codeclimate.com/github/ysugimoto/node-memcached-client)

## 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

```shell
$ npm install node-memcached-client
```

## Usage

Callback style connect:

```js
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:

```js
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

|         name         |   type  | default value |            description                   |
|:--------------------:|:-------:|:-------------:|:----------------------------------------:|
|         host         |  string |  'localhost'  |    Memcached server to connect           |
|         port         |  Number |     11211     |     Memcached port to connect            |
|     autoreconnect    | Boolean |     false     |     Client tries to reconnect            |
|     commandTimeout   |  Number |     2000      | Duration times of command timeout (msec) |
|   reconnectDuration  |  Number |      2000     | Duration times of reconnect (msec)       |
| maxRetryConnectCount |  Numer  |       10      |      Retry times to reconnect            |

## Connection Pooling Settings

Pooling configuration enable to change by environment variables:

|                  name                 |  type  | default value |                   description                   |
|:-------------------------------------:|:------:|:-------------:|:-----------------------------------------------:|
|     MEMCACHED_CLIENT_MAX_POOL_SIZE    | Number |       1       | Connection pooling size per host:port signature |
| MEMCACHED_CLIENT_SCALE_THRESHOLD_SIZE | Number |      100      |     Threshold to increase client connection     |

---
_Source: https://npm.io/package/node-memcached-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
