# notcached

> Yet another memcached client written in TypeScript.

Latest version **2.0.0** (published 2020-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install notcached
pnpm add notcached
yarn add notcached
bun add notcached
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2020-04-26 |
| First published | 2020-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 82.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | takase1121 |
| Maintainers | takase1121 |
| Keywords | memcached, notcached, cache, storage, caching, key, value, store, memcache, nosql, InnoDB memcached API, client |

## Links

- npm: https://www.npmjs.com/package/notcached
- Repository: https://github.com/takase1121/notcached
- Homepage: https://takase1121.github.io/notcached
- Issues: https://github.com/takase1121/notcached/issues
- npm.io page: https://npm.io/package/notcached

## Dependencies (3)

- [ow](https://npm.io/package/ow.md) ^0.17.0
- [tarn](https://npm.io/package/tarn.md) ^2.0.0
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.2.2

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

- 2.0.0 (latest) — 2020-04-26
- 1.1.2 — 2020-04-18
- 1.1.1 — 2020-04-18
- 1.1.0 — 2020-04-18
- 1.0.1 — 2020-04-18

## README

# Notcached
A Node.js Memcached client.

After using the `memcached` package, I was dissatisfied. `memcached` does not support promises and its not maintained anymore.
Even the fork `memecached` doesn't seem to be maintained either. So, I decided to write my own client instead.

### Features
- [x] Basic commands, eg. get, set
- [x] Pool for a single server
- [ ] Multiple server support with [ketama algorithm](https://www.metabrew.com/article/libketama-consistent-hashing-algo-memcached-clients)
- [ ] Meta commands
- [ ] Binary support
- [ ] SASL support
- [ ] Stream support (node.js `stream`)

### Documentations
[Here.](https://takase1121.github.io/notcached)

### Examples
```js
const { Notcached, createPool } = require('notcached');
const MEMCACHED_SERVER_LOCATION = 'localhost:11211';

const client = new Notcached(SERVER_LOCATION, {
    debug: false, // can be boolean or a function. I recommend using boolean and listen to 'debug' event
    retries: 3,  // number of retries before giving up
    retryTime: 3000, // time in milliseconds to wait before the client attempt to reconnect
    timeout: Infinity, // socket timeout, better leave this Infinity
    connectionTimeout: 3000, // time in milliseconds the before client tries to reconnect
    tcp: {}, // tcp options. Usually you don't need to specify this
    legacyFlags: true // leave this to true for backwards compatibility. Please see FAQ
});

// make sure results are returned in strings
client.string();

// setting something
await client.set('hey', 'hello world!', 0, 12);

// getting something
const val = await client.get('hey');
console.log(val); // prints: { 'hey': { data: 'hello world!', flags: 12 } }

const pool = createPool(MEMCACHED_SERVER_LOCATION, { min: 2, max: 10 }); // the pool options accept tarn.js options

// you can directly do something with it 
pool.set('hey', 'hello world!');

// if you really need to manually acquire connection, you can access the pool at `pool.pool`
const connection = await pool.pool.acquire().promise;

// do things with this connection

// release it
pool.pool.release(pool);
```

This is some examples for common usages of the library. For more info, visit the [documentation](https://takase1121.github.io/notcached).

> Please note that the pooling capabilities of this library comes from [tarn.js](https://github.com/Vincit/tarn.js). You should visit them for more examples on how to use the pool.


### Memcached FAQ
[Here.](https://github.com/takase1121/notcached/blob/master/FAQ.md)

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