A thunk/promise-based redis client, support all redis features.
redis.createClient([port], [host], [options])
redis.createClient([addressArray], [options])
port: Number
, default: 6379
;
host: String
, default: 'localhost'
;
options: Object
, default: {}
;
Create a redis client, return the client.
var client1 = redis . createClient ( ) ;
var client2 = redis . createClient ( { database : 2 } ) ;
var client3 = redis . createClient ( 6379 , { database : 2 } ) ;
var client4 = redis . createClient ( '127.0.0.1:6379' , { database : 2 } ) ;
var client5 = redis . createClient ( 6379 , '127.0.0.1' , { database : 2 } ) ;
// connect to 2 nodes
var client6 = redis . createClient ( [ 6379 , 6380 ] )
var client7 = redis . createClient ( [ '127.0.0.1:6379' , '127.0.0.1:6380' ] ) // IPv4
var client8 = redis . createClient ( [ '[::1]:6379' , '[::1]:6380' ] ) // IPv6
var client = redis . createClient ( ) ;
client . info ( ) ( redis . log ) ;
redis . calcSlot ( '123456789' ) ; // => 12739
redis . calcSlot ( 118 ) ; // => 13162
client.on('close', function () {})
client.on('connect', function () {})
client.on('connection', function (connection) {})
client.on('warn', function (error) {})
client.on('error', function (error) {})
client.on('reconnecting', function (message) {})
client.on('subscribe', function (pattern, n) {})
client.on('unsubscribe', function (pattern, n) {})
client.on('psubscribe', function (pattern, n) {})
client.on('punsubscribe', function (pattern, n) {})
client.on('message', function (channel, message) {})
client.on('pmessage', function (pattern, channel, message) {})
client.on('monitor', function (message) {})
client.evalauto(script, numkeys, key, [key ...], arg, [arg ...])
client.del(key, [key ...]) | client.del([key1, key2, ...])
client.expire(key, seconds)
client.expireat(key, timestamp)
client.migrate(host, port, key, db, timeout, [COPY], [REPLASE])
client.object(subcommand, [key, [key ...]])
client.pexpire(key, milliseconds)
client.pexpireat(key, ms-timestamp)
client.rename(key, newkey)
client.renamenx(key, newkey)
client.restore(key, ttl, serialized-value)
client.sort(key, [BY pattern], [LIMIT offset count], [GET pattern [GET pattern ...]], [ASC | DESC], [ALPHA], [STORE destination])
client.scan(cursor, [MATCH pattern], [COUNT count])
client.append(key, value)
client.bitcount(key, [start], [end])
client.bitop(operation, destkey, key, [key ...])
client.bitpos(key, bit, [start], [end])
client.decrby(key, decrement)
client.getbit(key, offset)
client.getrange(key, start, end)
client.getset(key, value)
client.incrby(key, increment)
client.incrbyfloat(key, increment)
client.mget(key, [key ...]) | client.mget([key1, key2, ...])
client.mset(key, value, [key, value ...]) | client.mset(object)
client.msetnx(key, value, [key, value ...]) | client.msetnx(object)
client.psetex(key, milliseconds, value)
client.set(key, value, [EX seconds], [PX milliseconds], [NX|XX])
client.setbit(key, offset, value)
client.setex(key, seconds, value)
client.setrange(key, offset, value)
client.hdel(key, field, [field ...])
client.hexists(key, field)
client.hincrby(key, field, increment)
client.hincrbyfloat(key, field, increment)
client.hmget(key, field, [field ...])
client.hmset(key, field, value, [field, value ...]) | client.hmset(key, object)
client.hset(key, field, value)
client.hsetnx(key, field, value)
client.hscan(key, cursor, [MATCH pattern], [COUNT count])
client.blpop(key, [key ...], timeout)
client.brpop(key, [key ...], timeout)
client.brpoplpush(source, destination, timeout)
client.lindex(key, index)
client.linsert(key, BEFORE|AFTER, pivot, value)
client.lpush(key, value, [value ...])
client.lpushx(key, value)
client.lrange(key, start, stop)
client.lrem(key, count, value)
client.lset(key, index, value)
client.ltrim(key, start, stop)
client.rpoplpush(source, destination)
client.rpush(key, value, [value ...])
client.rpushx(key, value)
client.sadd(key, member, [member ...])
client.sdiff(key, [key ...])
client.sdiffstore(destination, key, [key ...])
client.sinter(key, [key ...])
client.sinterstore(destination, key, [key ...])
client.sismember(key, member)
client.smove(source, destination, member)
client.srandmember(key, [count])
client.srem(key, member, [member ...])
client.sunion(key, [key ...])
client.sunionstore(destination, key, [key ...])
client.sscan(key, cursor, [MATCH, pattern], [COUNT, count])
client.zadd(key, score, member, [score, member ...])
client.zcount(key, min, max)
client.zincrby(key, increment, member)
client.zinterstore(destination, numkeys, key, [key ...], [WEIGHTS, weight, [weight ...]], [AGGREGATE, SUM|MIN|MAX])
client.zlexcount(key, min, max)
client.zrange(key, start, stop, [WITHSCORES])
client.zrangebylex(key, min, max, [LIMIT, offset, count])
client.zrevrangebylex(key, min, max, [LIMIT, offset, count])
client.zrangebyscore(key, min, max, [WITHSCORES], [LIMIT, offset, count])
client.zrank(key, member)
client.zrem(key, member, [member ...])
client.zremrangebylex(key, min, max)
client.zremrangebyrank(key, start, stop)
client.zremrangebyscore(key, min, max)
client.zrevrange(key, start, stop, [WITHSCORES])
client.zrevrangebyscore(key, max, min, [WITHSCORES], [LIMIT, offset, count])
client.zrevrank(key, member)
client.zscore(key, member)
client.zunionstore(destination, numkeys, key, [key ...], [WEIGHTS, weight, [weight ...]], [AGGREGATE, SUM|MIN|MAX])
client.zscan(key, cursor, [MATCH, pattern] [COUNT, count])
client.pfadd(key, element, [element ...])
client.pfcount(key, [key ...])
client.pfmerge(destkey, sourcekey, [sourcekey ...])
client.psubscribe(pattern, [pattern ...])
client.publish(channel, message)
client.pubsub(subcommand, [argument, [argument ...])
client.punsubscribe(pattern [pattern ...])
client.subscribe(channel, [channel ...])
client.unsubscribe([channel, [channel ...]])
client.watch(key, [key ...])
client.eval(script, numkeys, key, [key ...], arg, [arg ...])
client.evalsha(sha1, numkeys, key, [key ...], arg, [arg ...])
client.evalauto(script, numkeys, key, [key ...], arg, [arg ...]) [custom command]
client.script('EXISTS', script, [script ...])
client.script('LOAD', script)
client.client('KILL', [ip:port], [ID, client-id], [TYPE, normal|slave|pubsub], [ADDR, ip:port], [SKIPME, yes/no])
client.client('PAUSE', timeout)
client.client('SETNAME', connection-name)
client.command('GETKEYS')
client.command('INFO', command-name, [command-name ...])
client.config('GET', parameter)
client.config('SET', parameter, value)
client.config('RESETSTAT')
client.debug('OBJECT', key)
client.shutdown([NOSAVE], [SAVE])
client.slaveof(host, port)
client.slowlog(subcommand, [argument])