syllabus
v1.1.0
Published
Σ Syllabus, a collection of helpers mix-ins to encode Redis commands and to decode Redis replies, builded upon Sermone.
Downloads
170
Maintainers
Readme
Σ Syllabus
Σ Syllabus, a collection of helpers mix-ins to encode Redis commands and to decode Redis replies, builded upon Sermone. Moreover, Syllabus mantains a cache for LUA scripts, using the Camphora module. See Syllabus.lua property.
It also uses the Hoar module to handle semantic versioning, then Bolgia and Abaco modules to get some utilities.
NOTE: If you need to handle bindings between Syllabus commands and Redis replies, take a look at ♎ Libra, it uses Train queue under the hood, to get a simple rollback mechanism for commands, and to gain some performances in some particular situations.
NOTE: If you need a full-featured Redis client, built with the help of ♎ Libra and Σ Syllabus modules, try ♠ Spade.
Now 190 Redis commands mix-ins are implemented.
Table of Contents
- Install
- Run Tests
- Run Benchmarks
- Constructor
- Sample Usage
- Properties, Methods
- Syllabus Commands
- MIT License
Install
$ npm install syllabus [-g]
// clone repo
$ git clone [email protected]:rootslab/syllabus.git
require:
var Syllabus = require( 'syllabus' );
Run Tests
$ cd syllabus/
$ npm test
Run Benchmarks
$ cd syllabus/
$ npm run bench
Constructor
Create an instance. Optionally it is possible to:
- enable development / informational mode, with a boolean.
- enable development mode and restrict commands available for a particular Redis version, passing a Semver string like "1.0.0".
var s = Syllabus( [ Boolean develop | String semver ] )
Sample Usage
Create a normal syllabus, then some syllabus in development mode.
var log = console.log
// production use
, syll = Syllabus()
// enable development mode
, full = Syllabus( true )
, recent = Syllabus( '2.6.0' )
, old = Syllabus( '2.4.0' )
, ancient = Syllabus( '1.0.0' )
;
log( full.size() );
log( recent.size() );
log( old.size() );
log( ancient.size() );
See examples.
Properties, Methods
Arguments within [ ] are optional.
Syllabus : {
/*
* A collection of Redis commands mix-ins.
*/
commands : { .. }
/*
* Redis commands categories/keywords.
*/
, types : { .. }
/*
* Use raw encoding for commands.
* It accepts 4 different signatures.
* See Sermone#encode.
*/
, encode : Function
/*
* Wrap all Syllabus commands with a function that gets
* as argument the result object from the command encoding.
*
* NOTE: It is useful to automatically enqueue or write
* an encoded command to a socket.
* See usage example in Spade code: https://github.com/rootslab/spade
*/
, wrap : function ( Function wrapper ) : Boolean
lua : {
/*
* The current initialized cache object/hash for LUA scripts,
* a Camphora instance.
*
* NOTE: This property will remain hidden/empty until you call
* the #init method to explicitly show the LUA cache for scripts.
*/
cache : null | Camphora
/*
* Initiliazing LUA script cache. Load all the files
* found in the './lib/lua/scripts' directory, into the
* cache; then encode all SCRIPT LOAD commands with
* resulting data from files.
* Optionally you could pass a config hash, as the last
* argument, to create a new cache instance.
*
* - All script files are loaded in the local cache, a list
* of SCRIPT LOAD encoded commands will be passed to this
* callback.
*
* 'onCacheLoaded' : function ( Array commands )
*
* - This callback will be executed after that the script file
* will be loaded into the local cache and successfully
* processed by Redis.
*
* 'onFileProcessed' : function ( Boolean is_err_reply, String scr_name, String scr_digest, String scr_txt, Boolean isLast )
*
* Syllabus default options are:
*
* 'cache_init_opt' : (default cache is pre-initialized with this options)
* {
* capacity : 128
* , encrypt_keys : false
* , algorithm : 'sha1'
* , input_encoding : 'binary'
* , output_encoding : 'hex'
* }
*
* See Camphora constructor options at https://github.com/rootslab/camphora#options.
*
* 'file_load_opt' :
* {
* // set encoding to utf8
* encoding : 'utf8'
* , flag : 'r'
* , payload : true
* , filepath : __dirname + '/scripts'
* }
*
* See Camphora#load options at https://github.com/rootslab/camphora#methods.
*/
, init : function ( Function onCacheLoaded, Function onFileProcessed [, Object file_load_opt [, Object cache_init_opt] ] ) : undefined
/*
* SCRIPT commands shortcuts that updating the cache.
*/
, script : {
/*
* Flush Syllabus.lua.cache. 'fback' function will be called with the number
* of elements flushed from the cache.
* It returns encoded "SCRIPT FLUSH" command for Redis.
*/
flush : function ( [ Function cback [, Function fback ] ] ) : Object
/*
* Load a key/script into the cache.
* 'lback' function will be called with an argument that represents the entry
* loaded in the cache, or undefined if an error occurs.
* It returns encoded "SCRIPT LOAD data" command for Redis.
*/
, load : function ( String key, String data [, Function cback [, Function lback ] ] ) : Object
/*
* Run a LUA script from the cache using its key/name.
* It returns encoded "EVALSHA digest" command.
*/
, run : function ( String sname, Array keys, Array args [, Function cback ] ) : Object
}
/*
* Wrap Syllabus.lua.scripts commands with a function that gets
* as argument the result object from the command encoding.
*
* NOTE: It is useful to automatically enqueue or write
* an encoded command to a socket.
* See usage example in Spade code: https//github.com/rootslab/spade
*/
, wrap: function ( fn ) : Boolean
/*
* an hash of utilities to format special replies.
*/
, formatters: {
/*
* format/convert a string like:
*
* - 'monitor 1404871788.612598 [0 127.0.0.1:35604] "ping"'
*
* to an object/hash:
*
* {
* ip: '127.0.0.1',
* port: 47573,
* db: 0,
* cmd: '"ping"',
* utime: 1405478664248,
* time: [ 1405478664, 248185 ]
* }
*
*/
monitor : function ( String message ) : Object
/*
* Format/convert a pubsub message to an object.
*
* NOTE: the 'formatter' function converts an Array like:
*
* - [ unsubscribe, 'channel', 0 ]
*
* to an object/hash:
*
* {
* type : 'unsubscribe'
* , chan : 'channel'
* . subs : 0
* }
*
* - [ 'message', 'channel', 'Hello folks!' ]
*
* to an object/hash:
*
* {
* type : 'message'
* , chan : 'channel'
* . msg : 'Hello folks!!'
* }
*/
, message : function ( Array message ) : Object
}
}
/* NOTE: methods below exist only in develop mode. */
/*
* Get some infos about a command.
*
* Example: Syllabus.info( 'PiNg' );
*
* Output is:
*
* {
* req: 'PiNg',
* name: 'ping',
* args: 0,
* type: 'connection',
* cmd: 'PING',
* sub: [],
* url: 'http://redis.io/commands/ping'
* rtype: '+|$|*',
* since: '1.0.0',
* hint: 'PING',
* descr: 'Ping the server.'
* }
*
* NOTE:
*
* - 'name' is the mix-in method name.
*
* - 'args' refers to the number of arguments expected by the command
* mix-in method, not by the original Redis command.
*
* - 'sub' collects command direct child(ren) for commands like:
* OBJECT REFCOUNT, PUBSUB CHANNELS, etc..
*
* - 'hint' is the Redis command infos, not the signature of mix-in method.
*
* - 'since' indicates the Redis version from which the command is available.
*
* - 'rtype' is the reply type expected from Redis, when the command will
* be write to socket.
* Redis reply types are:
* - ':' or integer reply.
* - '+' or simple string reply.
* - '$' or bulk string reply.
* - '*' or multibulk reply.
* - '-' or error reply.
*
*/
, info : function ( String cmd ) : Object
/*
* Stick or unstick the #info method to every
* command function.
*
* It returns the number of commands/items that
* were updated.
*
* Example: Syllabus.commands.object.info();
*
* NOTE: use false to unstick.
*/
, stick : function ( [ Boolean enable ] ) : Number
/*
* Get the current number of commands in the syllabus
* and of keywords types, #size method counts also empty
* parent commands.
*/
, size : function () : Number
/*
* the current version / semver string specified , or '*'
*/
, semver : String
}
Syllabus Commands
Every Syllabus command returns an obj/hash like this:
obj = {
/*
* an info property about the number of multibulk generated by the encoding.
*/
bulks : 2
// original command
, cmd : 'GET'
/*
* encoded command for the Redis Protocol,
* ready for being sent to socket
*/
, ecmd: '*2\r\n$3\r\nGET\r\n$1\r\n1\r\n'
/*
* 'fn' is an utility function to parse data replied by Redis after sending
* a command. For default is Bolgia#reveal function ( it converts Buffers to
* String and Numbers ), otherwise, depending on the command, the function
* could be also Abaco#parseIntArray, Abaco#parseFloatArray, etc..
*/
, fn : function ( Object data ) : Object
/*
* 'zn' is the callback function placeholder, for defaults it's an empty
* function; it could be specified passing a function as the last argument
* to any of command methods.
* See signatures below to check the correct syntax of a particular command.
*/
, zn : function ( err, data, fn ) : undefined
}
if an error occurs while encoding a command, the obj/hash will be something like:
obj = {
// command
, cmd : 'GET'
// current arguments for command mix-in
, arg : Array
// current Error instance
, err : Error
}
Command Types/Categories:
- Cluster : 1 command (19 missing).
- Connection : 6 commands.
- Geo : 6 commands.
- Hashes : 15 commands.
- HyperLogLog : 4 commands.
- Keys : 24 commands.
- Lists : 17 commands.
- PubSub : 6 commands.
- Scripting : 7 commands.
- Server : 31 commands.
- Sets : 15 commands.
- Sorted Sets : 21 commands.
- Strings : 23 commands, (1 missing).
- Transactions : 5 commands.
CLUSTER
Redis Cluster, 1 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
TODO: 19 commands
'cluster' : {
'slots' : function ( [ Function cback ] ) : Object
}
CONNECTION
Redis Connection, 6 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'auth' : function ( String password [, Function cback ] ) : Object
'echo' : function ( Number string | String string [, Function cback ] ) : Object
// legacy ping
'ping' : function ( [ Function cback ] ) : Object
// Redis >= 2.8.x ping, available also in pubsub mode
'ping' : function ( [ String message, [ Function cback ] ] ) : Object
'quit' : function ( [ Function cback ] ) : Object
'select' : function ( Number db | String db [, Function cback ] ) : Object
'swapdb' : function ( Number db | String db, Number odb | String odb, [, Function cback ] ) : Object
GEO
Redis GEO, 4 commands.
Arguments within [ ] are optional, '|' indicates multiple type for an argument.
TODO: GEORADIUS, GEORADIUSBYMEMBER commands.
'geoadd' : function ( Number key | String key | Array gpoints, [, Function cback ] ) : Object
'geohash' : function ( Number key | String key | Array members, [, Function cback ] ) : Object
'geodist' : function ( Number key | String key | Array members, [ String unit, [, Function cback ] ] ) : Object
'geopos' : function ( Number key | String key | Array members, [, Function cback ] ) : Object
/*
* georadius accepts an option Object:
*
* opt = {
* with : Array ( 'WITHCORD' 'WITHDIST' 'WITHASH' )
* , count : Number
* , order : String ( ASC | DESC )
* , store : Number | String
* , storedist : Number | String
* }
*
* Original Redis command is:
*
* GEORADIUS key long lat rad unit [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
*
* unit: m|km|ft|mi
*/
'georadius' : function ( Number | String key, Number | String long, Number | String lat, Number | String radius, String unit [, Object opt [, Function cback ] ] ) : Object
/*
* georadiusbymember accepts the same option Object as georadius:
*
* Original Redis command is:
*
* GEORADIUSBYMEMBER key member rad unit [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
*
* unit: m|km|ft|mi
*/
'georadiusbymember' : function ( Number | String key, Number | String member, Number | String radius, String unit [, Object opt [, Function cback ] ] ) : Object
HASHES
Redis Hashes, 15 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'hdel' : function ( Number key | String key, String field | Array fields [, Function cback ] ) : Object
'hexists' : function ( Number key | String key, String field [, Function cback ] ) : Object
'hget' : function ( Number key | String key, String field [, Function cback ] ) : Object
/*
* The fn utility returned by the #hgetall mix-in, is able to
* recursively convert the array/list reply to an obj/hash.
*
* NOTE: utility fn is Bolgia#toHash, optionally it accepts
* 3 further args:
*
* toHash( Array arr [, Boolean recur [, Object dest [, Boolean convert ] ] ] )
*
* - 'recur' id for de/activating recursion on nested arrays.
* - 'dest' Object could be null, or an object/hast to populate.
* - 'convert' enables automatic Buffer to String conversion, and
* String to Number conversion when it's possible.
*/
'hgetall' : function ( Number key | String key [, Function cback ] ) : Object
'hincrby' : function ( Number key | String key, String field, Number integer | String integer [, Function cback ] ) : Object
'hincrbyfloat' : function ( Number key | String key, String field, Number float | String float [, Function cback ] ) : Object
'hkeys' : function ( Number key | String key [, Function cback ] ) : Object
'hlen' : function ( Number key | String key [, Function cback ] ) : Object
/*
* The utility fn returned by the #hmget mix-in, is able to
* recursively convert the array/list reply to an obj/hash.
* See #hgetall about Bolgia#toHash.
*/
'hmget' : function ( Number key | String key, String field | Array fields ) : Object
/*
* hmset accepts an Array of fields and values or an Object:
*
* obj = {
* key1 : 'value1'
* key2 : 'value2'
* ..
* }
*
* Original Redis command is:
*
* HMSET key field value [field value ...]
*/
'hmset' : function ( Number key | array key, Array fvalues | Object fvalues [, Function cback ] ) : Object
'hset' : function ( Number key | String key, String field, Number value | String value [, Function cback ] ) : Object
'hsetnx' : function ( Number key | String key, String field, Number value | String value [, Function cback ] ) : Object
'hstrlen' : function ( Number key | String key, String field [, Function cback ] ) {
'hvals' : function ( Number key | String key [, Function cback ] ) : Object
/*
* hscan accepts an Array or on option Object:
*
* opt = {
* cursor : Number | String
* , match : String
* , count : Number | String
* }
*
* Original Redis command is:
*
* HSCAN key cursor [MATCH pattern] [COUNT count]
*/
'hscan' : function ( Number key | String key, Number cursor | String cursor, Object opt | Array args [, Function cback ] ) : Object
HYPERLOGLOG
Redis HyperLogLog, 4 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'pfadd' : function ( Number key | String key, String channel | Array channels [, Function cback ] ) : Object
'pfcount' : function ( Number key | String key | Array keys [, Function cback ] ) : Object
'pfmerge' : function ( Number dest | String dest, String source | Array sources [, Function cback ] ) : Object
'pfselftest' : function ( [ Function cback ] ) : Object
KEYS
Redis Keys, 24 commands.
NOTE: OBJECT is an empty parent command with 3 subcommands.
Arguments within [ ] are optional, '|' indicates multiple type for an argument.
'del' : function ( Number key | String key | Array keys [, Function cback ] ) : Object
'dump' : function ( Number key | String key [, Function cback ] ) : Object
'exists' : function ( Number key | String key [, Function cback ] ) : Object
'expire' : function ( Number key | String key, Number seconds [, Function cback ] ) : Object
'expireat' : function ( Number key | String key, Number unixtime [, Function cback ] ) : Object
'keys' : function ( [ String pattern [, Function cback ] ] ) : Object
/*
* migrate accepts an Array or on option Object:
*
* opt = {
* host : String
* , port : Number | String
* , db : Number | String
* , timeout : Number | String
* , action : [ String ]
* }
*
* Original Redis command is:
*
* 'MIGRATE host port key destination-db timeout [COPY] [REPLACE]'
*
*/
'migrate' : function( Number key | String key, Array args | Object opt [, Function cback ] ) : Object
'move' : function ( Number key | String key, String db | Number db [, Function cback ] ) : Object
'object' : {
'encoding' : function ( Number key | String key [, Function cback ] ) : Object
'idletime' : function ( Number key | String key [, Function cback ] ) : Object
'refcount' : function ( Number key | String key [, Function cback ] ) : Object
}
'persist' : function ( Number key | String key [, Function cback ] ) : Object
'pexpire' : function ( Number key | String key, Number millis [, Function cback ] ) : Object
'pexpireat' : function ( Number key | String key, Number unixtime [, Function cback ] ) : Object
'pttl' : function ( Number key | String key [, Function cback ] ) : Object
'randomkey' : function ( [ Function cback ] ) : Object
'rename' : function ( Number key | String key, String name | Number name [, Function cback ] ) : Object
'renamenx' : function ( Number key | String key, String name | Number name [, Function cback ] ) : Object
/*
* RESTORE gets a single Buffer as the last argument, like a reply from DUMP.
*
* Original Redis Command is:
*
* RESTORE key ttl serialized-value
*
*/
'restore' : function ( Number key | String key, Number ttl, Buffer data [, Function cback ] ) : Object
/*
* scan accepts an Array or on option Object:
*
* opt = {
* cursor : Number | String
* , match : String
* , count : Number | String
* }
*
* Original Redis command is:
*
* SCAN cursor [MATCH pattern] [COUNT count]
*/
'scan' : function ( Number cursor | String cursor, Object opt | Array args [, Function cback ] ) : Object
/*
* sort accepts an Array or on option Object:
*
* opt = {
* by : String
* , limit : Array
* , get : Array
* , order : String ( ASC | DESC | ALPHA )
* , store : Number | String
* }
*
* Original Redis command is:
*
* SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]
*/
'sort' : function ( Number key | String key, Object opt | Array args [, Function cback ] ) : Object
'touch' : function ( Array keys [, Function cback ] ) : Object
'ttl' : function ( Number key | String key [, Function cback ] ) : Object
'type' : function ( Number key | String key [, Function cback ] ) : Object
LISTS
Redis Lists, 17 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'blpop' : function ( Number key | String key, Number timeout | String timeout [, Function cback ] ) : Object
'brpop' : function ( Number key | String key, Number timeout | String timeout [, Function cback ] ) : Object
'brpoplpush' : function ( Number src | String src, Number dest | String dest, Number timeout | String timeout [, Function cback ] ) : Object
'lindex' : function ( Number key | String key, Number index | String index [, Function cback ] ) : Object
'linsert' : function ( Number key | String key, String pos, Number pivot | String pivot, Number val | String val [, Function cback ] ) : Object
'llen' : function ( Number key | String key [, Function cback ] ) : Object
'lpop' : function ( Number key | String key [, Function cback ] ) : Object
'lpush' : function ( Number src | String src, String value | Array values [, Function cback ] ) : Object
'lpushx' : function ( Number src | String src, String value [, Function cback ] ) : Object
'lrange' : function ( Number key | String key, Number start | String start, Number stop | String stop [, Function cback ] ) : Object
'lrem' : function ( Number key | String key, Number count | String count, Number val | String val [, Function cback ] ) : Object
'lset' : function ( Number key | String key, Number index | String index, Number val | String val [, Function cback ] ) : Object
'ltrim' : function ( Number key | String key, Number start | String start, Number stop | String stop [, Function cback ] ) : Object
'rpop' : function ( Number key | String key [, Function cback ] ) : Object
'rpoplpush' : function ( Number src | String src, Number dest | String dest [, Function cback ] ) : Object
'rpush' : function ( Number src | String src, String value | Array values [, Function cback ] ) : Object
'rpushx' : function ( Number src | String src, Number value | String value [, Function cback ] ) : Object
PUBSUB
Redis PubSub, 6 commands.
NOTE: PUBSUB is an empty parent command with 3 subcommands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'publish' : function ( String channel, String message [, Function cback ] ) : Object
'pubsub' : {
'channels' : function ( [ String pattern [, Function cback ] ] ) : Object
'numpat' : function ( [ Function cback ] ) : Object
'numsub' : function ( String channel | Array channels [, Function cback ] ) : Object
}
'psubscribe' : function ( String pattern | Array patterns [, Function cback ] ) : Object
'punsubscribe' : function ( String pattern | Array patterns [, Function cback ] ) : Object
'subscribe' : function ( Number channel | String channel | Array channels [, Function cback ] ) : Object
'unsubscribe' : function ( [ String channel | Array channels [, Function cback ] ] ) : Object
NOTE: to unsubscribe from all channels use null or [].
SCRIPTING
Redis Scripting, 7 commands.
NOTE: SCRIPT object is an empty parent command with 5 subcommands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
/*
* eval accepts 2 Arrays of keys and args.
*
* Original Redis command is:
*
* EVAL script numkeys key [key ...] arg [arg ...]
*/
'eval' : function ( String script, Array keys, Array args [, Function cback ] ) : Object
/*
* evalsha accepts 2 Arrays of keys and args.
*
* Original Redis command is:
*
* EVALSHA sha1 numkeys key [key ...] arg [arg ...]
*/
'evalsha' : function ( String sha, Array keys, Array args [, Function cback ] ) : Object
'script' : {
'exists' : function ( String key | Array keys [, Function cback ] ) : Object
'flush' : function ( [ Function cback ] ) : Object
'kill' : function ( [ Function cback ] ) : Object
'load' : function ( String key [, Function cback ] ) : Object
}
SERVER
Redis Server, 31 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'bgrewriteaof' : function ( [ Function cback ] ) : Object
'bgsave' : function ( [ Function cback ] ) : Object
'client' : {
'getname' : function ( [ Function cback ] ) : Object
'kill' : function ( Number key | String key, Number ip | String ip, Number port | String port [, Function cback ] ) : Object
/*
* The fn utility returned by the #list mix-in, is able to convert
* the reply to a list/array of hashes/objects, each listing infos
* for a distinct client.
*
* See http://redis.io/commands/client-list for a full explanation
* of properties.
*/
'list' : function ( [ Function cback ] ) : Object
'pause' : function ( Number millis | String millis [, Function cback ] ) : Object
'reply' : function ( String sw [, Function cback ] ) : Object
'setname' : function ( Number name | String name [, Function cback ] ) : Object
}
'config' : {
/*
* The utility fn returned by the #config.get mix-in,
* converts the array/list reply to an obj/hash, it
* converts ASCII Strings numbers to Numbers and
* strings 'yes' and 'no' to Booleans true/false.
*/
'get' : function ( String param [, Function cback ] ) : Object
'resetstat' : function ( [ Function cback ] ) : Object
'rewrite' : function ( [ Function cback ] ) : Object
'set' : function ( String param, Number value | String value [, Function cback ] ) : Object
}
'command' : {
/*
* COMMAND LIST doesn't exists; it is s a placeholder for COMMAND.
*/
'list' : function ( [ Function cback ] ) : Object
'info' : function ( String cmd | Array list [ Function cback ] ) : Object
'getkeys' : function ( String cmd | Array cmd [, Function cback ] ) : Object
'count' : function ( [ Function cback ] ) : Object
}
'dbsize' : function ( [ Function cback ] ) : Object
'debug' : {
'object' : function ( Number key | String key [, Function cback ] ) : Object
'segfault' : function ( [ Function cback ] ) : Object
}
// Redis >= 4.0.0 added ASYNC option
'flushall' : function ( [ Boolean async [, Function cback ] ] ) : Object
// or legacy version that accepts only an optional callback
'flushall' : function ( [ Function cback ] ) : Object
// Redis >= 4.0.0 added ASYNC option
'flushdb' : function ( [ Boolean async [, Function cback ] ) : Object
// or legacy version that accepts only an optional callback
'flushdb' : function ( [ Function cback ] ) : Object
/*
* The fn utility returned by the #info mix-in, is able to convert the
* reply to a 2-level deep hash, first level properties are Sections,
* at the second level there are section properties.
*
* See http://redis.io/commands/info for a full explanation of sections
* and properties.
*
* NOTE: The first argument of the utility fn could be a Buffer or a String.
*/
'info' : function ( [ String section [, Function cback ] ] ) : Object
'lastsave' : function ( [ Function cback ] ) : Object
'monitor' : function ( [ Function cback ] ) : Object
/*
* ROLE reply:
*
* - for MASTER: [ 'master', 155, [ [ '127.0.0.1', 6380, 155 ], [ '127.0.0.1', 6381, 155 ] ] ] ]
* - for SLAVE: [ 'slave','127.0.0.1', 6379,'connected', 155 ] ]
* - for SENTINEL: [ sentinel, [ 'master_name_1', ,,,, 'master_name_N' ] ]
*
* The utility fn passed to the callback, if applied to data, converts results in this way:
*
* - for a master:
* {
* type: 'master',
* replica_offset: 155,
* connected_slaves: [ [ '127.0.0.1', 6380, 155 ], [ '127.0.0.1', 6381, 155 ] ]
* }
*
* - for a slave:
* {
* type: 'slave',
* master_ip: '127.0.0.1',
* master_port: 6380,
* replica_status: 'connected',
* replica_offset: 155
* }
*
* - for a sentinel:
* {
* type: 'slave',
* master_names : [ 'master_name_1', ,,,, 'master_name_N' ]
* }
*/
'role' : function ( [ Function cback ] ) : Object
'save' : function ( [ Function cback ] ) : Object
'shutdown' : function ( [ String opt [, Function cback ] ] ) : Object
'slaveof' : function ( String host, Number port | String port [, Function cback ] ) : Object
'slowlog' : {
'get' : function ( Number integer | String integer [, Function cback ] ) : Object
'len' : function ( [ Function cback ] ) : Object
'reset' : function ( [ Function cback ] ) : Object
}
'sync' : function ( [ Function cback ] ) : Object
'time' : function ( [ Function cback ] ) : Object
SETS
Redis Sets, 15 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'sadd' : function ( Number key | String key, String member | Array members [, Function cback ] ) : Object
'scard' : function ( Number key | String key [, Function cback ] ) : Object
'sdiff' : function ( Number key | String key | Array keys [, Function cback ] ) : Object
'sdiffstore' : function ( Number dest | String dest, Number key | String key | Array keys [, Function cback ] ) : Object
'sinter' : function ( Number key | String key | Array keys [, Function cback ] ) : Object
'sinterstore' : function ( Number dest | String dest, Number key | String key | Array keys [, Function cback ] ) : Object
'sismember' : function ( Number key | String key, String member | Array members [, Function cback ] ) : Object
'smove' : function ( Number src | String src, Number dest | String dest, Number member | String member [, Function cback ] ) : Object
'smembers' : function ( Number key | String key [, Function cback ] ) : Object
'spop' : function ( Number key | String key [, Function cback ] ) : Object
'srandmember' : function ( Number key | String key, Number count | String count [, Function cback ] ) : Object
'srem' : function ( Number key | String key, Number member | String members | Array members [, Function cback ] ) : Object
/*
* sscan accepts an Array or on option Object:
*
* opt = {
* cursor : Number | String
* , match : String
* , count : Number | String
* }
*
* Original Redis command is:
*
* SSCAN key cursor [MATCH pattern] [COUNT count]
*/
'sscan' : function ( Number key | String key, Number cursor | String cursor, Object opt | Array args [, Function cback ] ) : Object
'sunion' : function ( Number key | String key | Array keys [, Function cback ] ) : Object
'sunionstore' : function ( Number dest | String dest, Number key | String key | Array keys [, Function cback ] ) : Object
SORTED SETS
Redis Sorted Sets, 21 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
/*
* zadd accepts an Array of scores and members or an Object:
*
* obj = {
* '1.5' : 'member1'
* '2' : 'member2'
* ..
* }
*
* Original Redis command is:
*
* ZADD key score member [score member ...]
*/
'zadd' : function ( Number key | string key, Array args | Object scores [, Function cback ] ) : Object
'zcard' : function ( Number key | String key [, Function cback ] ) : Object
'zcount' : function ( Number key | String key, Number min | String min, Number max | String max [, Function cback ] ) : Object
'zincrby' : function ( Number key | String key, Number integer | String integer, Number member | String member [, Function cback ] ) : Object
/*
* zinterstore optionally accepts an array of weights and an aggregate string option.
*
* Original Redis command is:
*
* ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]
*/
'zinterstore' : function ( Number dest | String dest, Array keys [, Array weights [, String aggregate [, Function cback ] ] ] ) : Object
'zlexcount' : function ( Number key | String key, Number min | String min, Number max | String max [, Function cback ] ) : Object
'zrange' : function ( Number key | String key, Number start | String start, Number stop | String stop [, Boolean withscores [, Function cback ] ] ) : Object
/*
* zrangebylex optionally accepts a limit array containing an offset and a count.
*
* Original Redis command is:
*
* ZRANGEBYLEX key min max [LIMIT offset count]
*/
'zrangebylex' : function ( Number key | String key, Number min | String min, Number max | String max [, Array limit [, Function cback ] ] ) : Object
/*
* zrevrangebylex optionally accepts a limit array containing an offset and a count.
*
* Original Redis command is:
*
* ZREVANGEBYLEX key min max [LIMIT offset count]
*/
'zrevrangebylex' : function ( Number key | String key, Number min | String min, Number max | String max [, Array limit [, Function cback ] ] ) : Object
'zrangebyscore' : function ( Number key | String key, Number min | String min, Number max | String max [, Boolean withscores [, Function cback ] ] ) : Object
'zrank' : function ( Number key | String key, Number member | String member [, Function cback ] ) : Object
'zrem' : function ( Number key | String key, Number member | String member | Array members [, Function cback ] ) : Object
'zremrangebylex' : function ( Number key | String key, Number min | String min, Number max | String max [, Function cback ] ) : Object
'zremrangebyrank' : function ( Number key | String key, Number start | String start, Number stop | String stop [, Function cback ] ) : Object
'zremrangebyscore' : function ( Number key | String key, Number min | String min, Number max | String max [, Function cback ] ) : Object
'zrevrank' : function ( Number key | String key, Number member | String member [, Function cback ] ) : Object
'zrevrange' : function ( Number key | String key, Number start | String start, Number stop | String stop [, Boolean withscores [, Function cback ] ] ) : Object
/*
* zrevrangebyscore optionally accepts a withscores boolean and a limit array containing an offset and a count.
*
* Original Redis command is:
*
* ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]
*/
'zrevrangebyscore' : function ( Number key | String key, Number start | String start, Number stop | String stop [, Boolean withscores [, Array limit [, Function cback ] ] ] ) : Object
/*
* zscan accepts an Array or on option Object:
*
* opt = {
* cursor : Number | String
* , match : String
* , count : Number | String
* }
*
* Original Redis command is:
*
* ZSCAN key cursor [MATCH pattern] [COUNT count]
*/
'zscan' : function ( Number key | String key, Number cursor | String cursor, Object opt | Array args [, Function cback ] ) : Object
'zscore' : function ( Number key | String key, Number member | String member [, Function cback ] ) : Object
/*
* zunionstore optionally accepts an array of weights and an aggregate string option.
*
* Original Redis command is:
*
* ZUNIONSTORE destination numkeys key [key ...] [WEIGHTS weight [weight ...]] [AGGREGATE SUM|MIN|MAX]
*/
'zunionstore' : function ( Number dest | String dest, Array keys [, Array weights [, String aggregate [, Function cback ] ] ] ) : Object
STRINGS
Redis Strings, 23 commands.
NOTE: BITTOP is an empty parent command with 4 subcommands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
TODO: BITFIELD command.
'append' : function ( Number key | String key, Number value | String value [, Function cback ] ) : Object
'bitcount' : function ( Number key | String key [, Array range [, Function cback ] ] ) : Object
'bittop' : {
'and' : function ( Number dest | String dest, Number key | String key | Array keys [, Function cback ] ) : Object
'not' : function ( Number dest | String dest, Number key | String key | Array keys [, Function cback ] ) : Object
'or' : function ( Number dest | String dest, Number key | String key | Array keys [, Function cback ] ) : Object
'xor' : function ( Number dest | String dest, Number key | String key | Array keys [, Function cback ] ) : Object
}
'bitpos' : function ( Number key | String key, Number pos | String pos [, Array range [, Function cback ] ] ) : Object
'decr' : function ( Number key | String key [, Function cback ] ) : Object
'decrby' : function ( Number key | String key, Number integer | String integer [, Function cback ] ) : Object
'get' : function ( Number key | String key [, Function cback ] ) : Object
'getbit' : function ( Number key | String key, Number offset | String offset [, Function cback ] ) : Object
'getrange' : function ( Number key | String key, String start | Number start, String end | Number end [, Function cback ] ) : Object
'getset' : function ( Number key | String key, Number value | String value [, Function cback ] ) : Object
'incr' : function ( Number key | String key [, Function cback ] ) : Object
'incrby' : function ( Number key | String key, Number integer | String integer [, Function cback ] ) : Object
'incrbyfloat' : function ( Number key | String key, String float | Number float [, Function cback ] ) : Object
'mget' : function ( Number key | String key | Array keys [, Function cback ] ) : Object
/*
* mset accepts an Array of fields and values or an Object:
*
* obj = {
* key1 : 'value1'
* key2 : 'value2'
* ..
* }
*
* Original Redis command is:
*
* MSET key value [key value ...]
*/
'mset' : function ( Array args | Object fvalues [, Function cback ] ) : Object
/*
* msetnx accepts an Array of fields and values or an Object:
*
* obj = {
* key1 : 'value1'
* key2 : 'value2'
* ..
* }
*
* Original Redis command is:
*
* MSETNX key value [key value ...]
*/
'msetnx' : function ( Array args | Object fvalues [, Function cback ] ) : Object
'psetex' : function ( Number key | String key, String millis | Number millis, Number val | String val [, Function cback ] ) : Object
/*
* set accepts an Array or on option Object:
*
* opt = {
* ex : String | Number
* , px : String | Number
* , check : String ( NX | XX )
* }
*
* Original Redis command is:
*
* SET key value [EX seconds] [PX milliseconds] [NX|XX]
*/
'set' : function ( Number key | String key, Number val | String val [, Array args | Object options [, Function cback ] ] ) : Object
'setbit' : function ( Number key | String key, Number offset | String offset, Number val | String val [, Function cback ] ) : Object
'setex' : function ( Number key | String key, Number secs | String secs, Number value | String value [, Function cback ] ) : Object
'setnx' : function ( Number key | String key, Number value | String value [, Function cback ] ) : Object
'setrange' : function ( Number start | String start, Number offset | String offset, Number val | String val [, Function cback ] ) : Object
'strlen' : function ( Number key | String key [, Function cback ] ) : Object
TRANSACTIONS
Redis Transactions, 5 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'discard' : function ( [ Function cback ] ) : Object
'exec' : function ( [ Function cback ] ) : Object
'multi' : function ( [ Function cback ] ) : Object
'watch' : function ( Number key | String key | Array keys [, Function cback ] ) : Object
'unwatch' : function ( [ Function cback ] ) : Object
MIT License
Copyright (c) 2013-present < Guglielmo Ferri : [email protected] >
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.