0.12.0 • Published 6 years ago
kt-client v0.12.0
kt-client
KyotoTycoon client for Node.js
Installation
npm install kt-clientSetting up the client
const KyotoTycoon = require('kt-client');
const kt = new KyotoTycoon(options);Options
host: String KyotoTycoon serverport: Number port number
API
kt.get(key, options, callback)
key: String the name of the keyoptions: Object optionscallback: Function the callback
kt.get('foo', (error, value) => {
console.log(value);
});kt.set(key, value, options, callback)
key: String the name of the keyvalue: Mixed valueoptions: Object optionscallback: Function the callback
kt.set('foo', 'bar', (error) => {
console.log(error);
});kt.add(key, value, options, callback)
key: String the name of the keyvalue: Mixed valueoptions: Object optionscallback: Function the callback
kt.add('foo', 'bar', (error) => {
console.log(error);
});kt.replace(key, value, options, callback)
key: String the name of the keyvalue: Mixed valueoptions: Object optionscallback: Function the callback
kt.replace('foo', 'bar', (error) => {
console.log(error);
});kt.remove(key, callback)
key: String the name of the keycallback: Function the callback
kt.remove('foo', (error) => {
console.log(error);
});kt.void(callback)
callback: Function the callback
kt.void((error) => {
console.log(error);
});kt.echo(callback)
params: Object arbitrary recordscallback: Function the callback
kt.echo({foo: 'bar'}, (error, data) => {
console.log(data.foo); // => bar
});kt.report(callback)
callback: Function the callback
kt.report((error, data) => {
Object.keys(data).forEach((key) => {
console.log(`key: ${key}, value: ${data[key]}`);
});
});kt.status(options, callback)
options: Object optionscallback: Function the callback
kt.status((error, data) => {
Object.keys(data).forEach((key) => {
console.log(`key: ${key}, value: ${data[key]}`);
});
});kt.clear(options, callback)
options: Object optionscallback: Function the callback
kt.clear((error) => {
console.log(error);
});kt.append(key, value, options, callback)
key: String the name of the keyvalue: Mixed valueoptions: Object optionscallback: Function the callback
kt.append(key, value, (error) => {
console.log(error);
});kt.increment(key, num, options, callback)
key: String the name of the keynum: Number the additional numberoptions: Object optionscallback: Function the callback
kt.increment(key, num, (error, num) => {
console.log(num);
});kt.incrementDouble(key, num, options, callback)
key: String the name of the keynum: Number the additional numberoptions: Object optionscallback: Function the callback
kt.incrementDouble(key, num, (error, num) => {
console.log(num);
});kt.cas(key, oldValue, newValue, options, callback)
key: String the name of the keyoldValue: Mixed the old valuenewValue: Mixed the new valueoptions: Object optionscallback: Function the callback
kt.cas(key, oldValue, newValue, (error) => {
console.log(err);
});kt.check(key, options, callback)
key: String the name of the keyoptions: Object optionscallback: Function the callback
kt.check(key, (error, size, expire) => {
console.log(size);
console.log(expire);
});kt.seize(key, options, callback)
key: String the name of the keyoptions: Object optionscallback: Function the callback
kt.seize(key, (error, value, expire) => {
console.log(value);
console.log(expire);
});kt.setBulk(records, options, callback)
records: Object the recordsoptions: Object optionscallback: Function the callback
kt.setBulk(records, (error) => {
console.log(error);
});kt.removeBulk(records, options, callback)
keys: Array the key of the recordoptions: Object optionscallback: Function the callback
kt.removeBulk(keys, (error) => {
console.log(error);
});kt.getBulk(records, options, callback)
keys: Array the key of the recordoptions: Object optionscallback: Function the callback
kt.getBulk(keys, (error, ret) => {
console.log(ret.key);
});kt.vacuum(options, callback)
options: Object optionscallback: Function the callback
kt.vacuum((error) => {
console.log(error);
});kt.matchPrefix(prefix, options, callback)
prefix: String the prefix stringoptions: Object optionscallback: Function the callback
kt.matchPrefix('foo', (error, data) => {
data.forEach((v) => {
console.log(v);
});
});kt.matchRegex(regex, options, callback)
regex: String the regular expression stringoptions: Object optionscallback: Function the callback
kt.matchRegex('foo.*', (error, data) => {
data.forEach((v) => {
console.log(v);
});
});kt.matchSimilar(origin, options, callback)
origin: String the origin stringoptions: Object optionscallback: Function the callback
kt.matchSimilar('foo', (error, data) => {
data.forEach((v) => {
console.log(v);
});
});