libmemcached
Node.js bindings to the libMemcached library.
Table of contents
- Requirements
- Installation
- Usage
- API
- constructor(config: string)
- set(key: string, value: Buffer|string|number, expiration?:integer=0): this
- add(key: string, value: Buffer|string|number, expiration?:integer=0): this
- replace(key: string, value: Buffer|string|number, expiration?:integer=0): this
- append(key: string, value: Buffer|string|number, expiration?:integer=0): this
- prepend(key: string, value: Buffer|string|number, expiration?:integer=0): this
- get(key: string): Buffer|undefined
- exist(key: string): boolean
- touch(key: string, expiration: integer): this
- delete(key: string): this
- increment(key: string, offset?: integer=1): integer
- decrement(key: string, offset?: integer=1): integer
Requirements
memcached
>= 1.4.14libmemcached
>= 1.0.18libmemcached-dev
gcc
with c++11
Installation
npm install libmemcached --save
or
yarn add libmemcached
Usage
const MemcachedClient =
API
constructor(config: string)
Initialize client.
config
parameter is a libMemcached configuration string.
const mcc = '--SERVER=127.0.0.1'
set(key: string, value: Buffer|string|number, expiration?:integer=0): this
Store item.
mcc
Function throws Error
when:
- key is not provided
- when value is not provided
Function throws TypeError
when:
- when value is boolean, null, undefined, function, object or array
try mcccatcherr console
add(key: string, value: Buffer|string|number, expiration?:integer=0): this
Add item. If key does exist - do nothing.
mcc
Function throws Error
when:
- key is not provided
- when value is not provided
Function throws TypeError
when:
- when value is boolean, null, undefined, function, object or array
try mcccatcherr console
replace(key: string, value: Buffer|string|number, expiration?:integer=0): this
Replace item. If key doesn't exist - do nothing.
mcc
Function throws Error
when:
- key is not provided
- when value is not provided
Function throws TypeError
when:
- when value is boolean, null, undefined, function, object or array
try mcccatcherr console
append(key: string, value: Buffer|string|number, expiration?:integer=0): this
Append value to existing item. If key doesn't exist - do nothing.
mcc
Function throws Error
when:
- key is not provided
- when value is not provided
Function throws TypeError
when:
- when value is boolean, null, undefined, function, object or array
try mcccatcherr console
prepend(key: string, value: Buffer|string|number, expiration?:integer=0): this
Prepend value to existing item. If key doesn't exist - do nothing.
mcc
Function throws Error
when:
- key is not provided
- when value is not provided
Function throws TypeError
when:
- when value is boolean, null, undefined, function, object or array
try mcccatcherr console
get(key: string): Buffer|undefined
Get item.
let val = mcc
Function throws Error
when:
- key is not provided
try let key let val = mcccatcherr console
Function returns undefined
when key doesn't exist.
exist(key: string): boolean
Determine if a item exists.
if mcc console else console
Function throws Error
when:
- key is not provided
try let key mcccatcherr console
touch(key: string, expiration: integer): this
Update the expiration time of an existing item without fetching it.
mcc
Function throws Error
when:
- key is not provided
Function throws TypeError
when:
- expiration isn't integer
try mcccatcherr console
delete(key: string): this
Remove a item.
mcc
Function throws Error
when:
- key is not provided
- key is not exist
try mcccatcherr console
increment(key: string, offset?: integer=1): integer
Incrementing item.
let key = mcc
Function throws Error
when:
- key is not provided
- key is not exist
Function throws TypeError
when:
- item is not integer
- offset is not integer
try let key = mcccatcherr console
decrement(key: string, offset?: integer=1): integer
Decrementing item.
let key = mcc
Function throws Error
when:
- key is not provided
- key is not exist
Function throws TypeError
when:
- item is not integer
- offset is not integer
try let key = mcccatcherr console