redis-connection-pool.js

Summary
redis-connection-pool.js
Functions
RedisConnectionPoolA high-level redis management object.
onlisten for redis events
expireExecute a redis EXPIRE command
setExecute a redis SET command
getExecute a redis GET command
delExecute a redis DEL command
hsetExecute a redis HSET command
hgetExecute a redis HGET command
hgetallExecute a redis HGETALL command
rpushExecute a redis RPUSH command
lpushExecute a redis LPUSH command
blpopExecute a redis BLPOP command
brpopExecute a redis BRPOP command
cleanClean the redis key namespace
checkPerforms a check on redis version and sets internal config based on support.

Functions

RedisConnectionPool

function RedisConnectionPool(uid,
cfg)

A high-level redis management object.  It manages a number of connections in a pool, using them as needed and keeping all aspects of releasing active connections internal to the object, so the user does not need to worry about forgotten connections leaking memory and building up over time.

Parameters

uid(string) - Unique identifer to retreive an existing instance from elsewhere in an application.  If left undefined, one will be generate automatically and avaialble via the `uid` property of the returned object.
cfg(object) - A series of configuration parameters to be optionally passed in and used during initialization of the object.
cfg.host(string) - Redis host (default: “127.0.0.1”)
cfg.port(number) - Redis port (default: 6379)
cfg.max_clients(number) - Max clients alive in the connection pool at once.  (default: 30)
cfg.perform_checks(boolean) - Perform a series of redis checks, currently this checks to to see if blocking push/pops can be used.  (default: false)

Returns

A RedisConnectionPool object

on

RedisConnectionPool.prototype.on = function(type,
cb)

listen for redis events

Parameters

type(string) - Type of event to listen for.
cb(function) - Callback function when the event is triggered.

expire

RedisConnectionPool.prototype.expire = function (key,
data)

Execute a redis EXPIRE command

Parameters

key(string) - A key to assign value to
value(number) - TTL in seconds

set

RedisConnectionPool.prototype.set = function (key,
data,
cb)

Execute a redis SET command

Parameters

key(string) - A key to assign value to
data(string) - Value to assign to key
cb(function) - Callback to be executed on completion

get

RedisConnectionPool.prototype.get = function (key,
cb)

Execute a redis GET command

Parameters

key(string) - The key of the value you wish to get
cb(function) - Callback to be executed on completion

del

RedisConnectionPool.prototype.del = function (key)

Execute a redis DEL command

Parameters

key(string) - The key of the value you wish to delete

hset

RedisConnectionPool.prototype.hset = function (key,
field,
data,
cb)

Execute a redis HSET command

Parameters

key(string) - A key to assign the hash to
field(string) - Name of the field to set
data(string) - Value to assign to hash
cb(function) - Callback to be executed on completion

hget

RedisConnectionPool.prototype.hget = function (key,
field,
cb)

Execute a redis HGET command

Parameters

key(string) - The key of the hash you wish to get
field(string) - The field name to retrieve
cb(function) - Callback to be executed on completion

hgetall

RedisConnectionPool.prototype.hgetall = function (key,
cb)

Execute a redis HGETALL command

Parameters

key(string) - The key of the hash you wish to get
cb(function) - Callback to be executed on completion

rpush

RedisConnectionPool.prototype.rpush = function (key,
data,
cb)

Execute a redis RPUSH command

Parameters

key(string) - The list key
data(string) - Value to assign to the list
cb(function) - Callback to be executed on completion

lpush

RedisConnectionPool.prototype.lpush = function (key,
data,
cb)

Execute a redis LPUSH command

Parameters

key(string) - The list key
data(string) - Value to assign to the list
cb(function) - Callback to be executed on completion

blpop

RedisConnectionPool.prototype.blpop = function (key,
cb)

Execute a redis BLPOP command

Parameters

key(string) - The list key
cb(function) - Callback to be executed on completion

brpop

RedisConnectionPool.prototype.brpop = function (key,
cb)

Execute a redis BRPOP command

Parameters

key(string) - The list key
cb(function) - Callback to be executed on completion

clean

RedisConnectionPool.prototype.clean = function (key,
cb)

Clean the redis key namespace

Parameters

key(string) - The key of the value you wish to clear (can use wildcard *)
cb(function) - Callback to be executed on completion

check

RedisConnectionPool.prototype.check = function ()

Performs a check on redis version and sets internal config based on support.

This function is for compatibility checking, you don’t normally need this.

Returns

promise which, upon completion, will return a version number as a string.

function RedisConnectionPool(uid,
cfg)
A high-level redis management object.
RedisConnectionPool.prototype.on = function(type,
cb)
listen for redis events
RedisConnectionPool.prototype.expire = function (key,
data)
Execute a redis EXPIRE command
RedisConnectionPool.prototype.set = function (key,
data,
cb)
Execute a redis SET command
RedisConnectionPool.prototype.get = function (key,
cb)
Execute a redis GET command
RedisConnectionPool.prototype.del = function (key)
Execute a redis DEL command
RedisConnectionPool.prototype.hset = function (key,
field,
data,
cb)
Execute a redis HSET command
RedisConnectionPool.prototype.hget = function (key,
field,
cb)
Execute a redis HGET command
RedisConnectionPool.prototype.hgetall = function (key,
cb)
Execute a redis HGETALL command
RedisConnectionPool.prototype.rpush = function (key,
data,
cb)
Execute a redis RPUSH command
RedisConnectionPool.prototype.lpush = function (key,
data,
cb)
Execute a redis LPUSH command
RedisConnectionPool.prototype.blpop = function (key,
cb)
Execute a redis BLPOP command
RedisConnectionPool.prototype.brpop = function (key,
cb)
Execute a redis BRPOP command
RedisConnectionPool.prototype.clean = function (key,
cb)
Clean the redis key namespace
RedisConnectionPool.prototype.check = function ()
Performs a check on redis version and sets internal config based on support.
Close