ali-sdk/ali-mc

Name: ali-mc

Owner: ali-sdk

Description: Aliyun OCS(open cache storage) client. (Just a Memcache client)

Created: 2015-12-28 06:24:39.0

Updated: 2017-11-01 01:54:42.0

Pushed: 2016-11-11 14:30:22.0

Homepage:

Size: 57

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

ali-mc

NPM version build status Test coverage David deps Known Vulnerabilities npm download

AliCloudDB for Memcache client. A standard implemetation of memcached binary protocol, and is compatible with spymemcached-2.12.0.jar.

Install
install ali-mc --save
Usage
new MCClient(options)

Create a mc client instance.

Parameters:

Example:

t MemcacheClient = require('ali-mc');

t client = new MemcacheClient({
st: ${host},
rt: ${port},
ername: ${username},
ssword: ${password},
 protocol: ${protocol}, // default is `binary`, also can use `text`
 responseTimeout: 50,
 logger: console,

.ready(callback)

If the client is ready for services, callback function will be called.

Otherwise all method will return The server is not available!;

.get(key[, callback])

Get the item with specified key.

Parameters:

Return:

Example:

all with callback
et(${someKey}, function(err, value) {
 (err) {
return console.log(err);

nsole(value);


all without callback
t co = require('co');
unction *() {
y {
let value = yield mc.get(${someKey});
console.log(value);
catch(err) {
console.log(err);


.set(key, value[, expired, callback])
.add(key, value[, expired, callback])
.replace(key, value[, expired, callback])

Set should store the data unconditionally if the item exists or not. Add MUST fail if the item already exist. Replace MUST fail if the item doesn't exist.

Parameters:

Return:

.delete(key[, callback])

Delete the item with specified key.

Parameters:

Return:

.increment(key[, step, callback])
.decrement(key[, step, callback])

Add or remove the specified amount to the requested counter.

Increment will cause the counter to wrap if it is up to the max value of 64 bit unsigned int.

Decrement will never result in a “negative value” (or cause the counter to “wrap”)

Parameters:

Return:

Example:

ncrement(${someKey}, function(err, value) { ... });

bove is equal to
ncrement(${someKey}, 1, function(err, value) { ... });

lso is equal to
ncrement(${someKey}, {
ep: 1,
unction(err, value) { ... });
.flush([expired, callback])

Flush the items in the cache now or some time in the future as specified by the “expired” field.

Parameters:

Return:

.version([callback])

Request the server version.

Parameters:

Return:

.append(key, value[, callback])
.prepend(key, value[, callback])

Append or prepend the specified value to the requested key.

Parameters:

Return:

Example:

ppends "!" to the "Hello" key
ppend('Hello', '!', function(err) { ... });
.touch(key[, expired, callback])

Change the item's expiration.

Parameters:

Return:

.gat(key[, expired, callback])

All the same with .touch() except this it will return the value of the spcified key. Text protocol not support

.close()

Close the client, you should listen the 'close' event to confirm that the client closes.

Event: 'error'

Emitted when an error occurs.

Parameters:

Event: 'close'

Emitted when the client closes.

References
License
MIT License (MIT)
right (c) 2016 fool2fish <fool2fish@gmail.com> and other contributors

ission is hereby granted, free of charge, to any person obtaining
py of this software and associated documentation files (the "Software"),
eal in the Software without restriction, including without limitation
rights to use, copy, modify, merge, publish, distribute, sublicense,
or sell copies of the Software, and to permit persons to whom the
ware is furnished to do so, subject to the following conditions:

above copyright notice and this permission notice shall be included
ll copies or substantial portions of the Software.

SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
ESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
R LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
R DEALINGS IN THE SOFTWARE.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.