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
- Basic commands, eg. get, set
- Pool for a single server
- Multiple server support with ketama algorithm
- Meta commands
- Binary support
- SASL support
- Stream support (node.js
stream
)
Documentations
Examples
const Notcached createPool = ;const MEMCACHED_SERVER_LOCATION = 'localhost:11211'; const client = 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 stringsclient; // setting somethingawait client; // getting somethingconst val = await client;console; // prints: { 'hey': { data: 'hello world!', flags: 12 } } const pool = ; // the pool options accept tarn.js options // you can directly do something with it pool; // if you really need to manually acquire connection, you can access the pool at `pool.pool`const connection = await poolpoolpromise; // do things with this connection // release itpoolpool;
This is some examples for common usages of the library. For more info, visit the documentation.
Please note that the pooling capabilities of this library comes from tarn.js. You should visit them for more examples on how to use the pool.