trooba-memcached-transport
A Memcached transport for trooba pipeline. All APIs of Memcached are supported in this transport.
Installation
npm install trooba-memcached-transport --save
Usage
var memcachedTransport = ; const client = ; await client;const retrievedValue = await client;console;
Get Involved
- Contributing: Pull requests are welcome!
- Read
CONTRIBUTING.md
and check out our bite-sized and help-wanted issues - Submit github issues for any feature enhancements, bugs or documentation problems
- Read
- Support: Join our gitter chat to ask questions to get support from the maintainers and other Trooba developers
- Questions/comments can also be posted as github issues
Setting up memcached client
You can setup memcached client by configuring three properties clientId
, servers
and options
.
clientid
- an unique identifier associated with memcached client.servers
- location of memcached servers. Please refer to the documentation here on various ways to configure server locations.options
- various options to configure the connection. Please refere to the documentation here for various options to configure.
const configs = clientId: '<an unique id>' servers: '<location of memcached servers>' options: '<options to configure the client>' ; const client = ;
API
client.touch Touches the given key.
key
: String The keylifetime
: Number After how long should the key expire measured inseconds
await client;
client.get Get the value for the given key.
key
: String, the key
const data = await clientconsole;
client.gets Get the value and the CAS id.
key
: String, the key
const data = await client;console;console;
client.getMulti Retrieves a bunch of values from multiple keys.
keys
: Array, all the keys that needs to be fetched
const data = await client;console;console;
client.set Stores a new value in client.
key
: String the name of the keyvalue
: Mixed Either a buffer, JSON, number or string that you want to store.lifetime
: Number, how long the data needs to be stored measured inseconds
client;
client.replace Replaces the value in client.
key
: String the name of the keyvalue
: Mixed Either a buffer, JSON, number or string that you want to store.lifetime
: Number, how long the data needs to be replaced measured inseconds
await client;
client.add Add the value, only if it's not in client already.
key
: String the name of the keyvalue
: Mixed Either a buffer, JSON, number or string that you want to store.lifetime
: Number, how long the data needs to be replaced measured inseconds
await client;
client.cas Add the value, only if it matches the given CAS value.
key
: String the name of the keyvalue
: Mixed Either a buffer, JSON, number or string that you want to store.lifetime
: Number, how long the data needs to be replaced measured inseconds
cas
: String the CAS value
const data = await client;await client;
client.append Add the given value string to the value of an existing item.
key
: String the name of the keyvalue
: Mixed Either a buffer, JSON, number or string that you want to store.
await client;
client.prepend Add the given value string to the value of an existing item.
key
: String the name of the keyvalue
: Mixed Either a buffer, JSON, number or string that you want to store.
await client;
client.incr Increment a given key.
key
: String the name of the keyamount
: Number The increment
await client;
client.decr Decrement a given key.
key
: String the name of the keyamount
: Number The increment
await client;
client.del Remove the key from client.
key
: String the name of the key
await client;
client.version Retrieves the version number of your server.
client.flush Flushes the client server.
client.stats Retrieves stats from your client server.
client.settings Retrieves your stats settings
.
client.slabs Retrieves stats slabs
information.
client.items Retrieves stats items
information.
client.end Closes all active client connections.