- Notifications
You must be signed in to change notification settings - Fork0
Σ Syllabus, a collection of helpers mix-ins to encode Redis commands, builded upon Sermone.
License
rootslab/syllabus
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Σ Syllabus, a collection of helpers mix-ins to encodeRedis commands and to decodeRedis replies, builded uponSermone. Moreover, Syllabus mantains acache forLUA scripts, using theCamphora module. SeeSyllabus.lua property.
It also uses theHoar module to handle semantic versioning, thenBolgia andAbaco modules to get some utilities.
NOTE: If you need to handle bindings betweenSyllabus commands andRedis replies, take a look at♎ Libra, it usesTrain queue under the hood, to get a simplerollback mechanism for commands, and to gain some performances in some particular situations.
NOTE: If you need a full-featuredRedis client, built with the help of♎ Libra andΣ Syllabus modules, try♠ Spade.
Now190 Redis commands mix-ins are implemented.
- Install
- Run Tests
- Run Benchmarks
- Constructor
- Sample Usage
- Properties, Methods
- Syllabus Commands
- MIT License
$ npm install syllabus [-g]// clone repo$ git clone git@github.com:rootslab/syllabus.git
require:
varSyllabus=require('syllabus');
$cd syllabus/$ npmtest
$cd syllabus/$ npm run bench
Create an instance.Optionally it is possible to:
- enable development / informational mode, with a boolean.
- enable development mode and restrict commands available for aparticularRedis version, passing aSemver stringlike"1.0.0".
vars=Syllabus([Booleandevelop|Stringsemver])
Create a normal syllabus, then some syllabus in development mode.
varlog=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());
Seeexamples.
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(Functionwrapper) :Booleanlua :{/* * 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(FunctiononCacheLoaded,FunctiononFileProcessed[,Objectfile_load_opt[,Objectcache_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([Functioncback[,Functionfback]]) :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(Stringkey,Stringdata[,Functioncback[,Functionlback]]) :Object/* * Run a LUA script from the cache using its key/name. * It returns encoded "EVALSHA digest" command. */,run :function(Stringsname,Arraykeys,Arrayargs[,Functioncback]) :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(Stringmessage) :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(Arraymessage) :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(Stringcmd) :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([Booleanenable]) :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}
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(Objectdata) :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 anerror occurs while encoding a command, the obj/hash will besomething 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.
RedisCluster, 1 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
TODO: 19 commands
'cluster' :{'slots' :function([Functioncback]) :Object}
RedisConnection, 6 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'auth' :function(Stringpassword[,Functioncback]) :Object'echo' :function(Numberstring|Stringstring[,Functioncback]) :Object// legacy ping'ping' :function([Functioncback]) :Object// Redis >= 2.8.x ping, available also in pubsub mode'ping' :function([Stringmessage,[Functioncback]]) :Object'quit' :function([Functioncback]) :Object'select' :function(Numberdb|Stringdb[,Functioncback]) :Object'swapdb' :function(Numberdb|Stringdb,Numberodb|Stringodb,[,Functioncback]) :Object
RedisGEO, 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
RedisHashes, 15 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'hdel' :function(Numberkey|Stringkey,Stringfield|Arrayfields[,Functioncback]) :Object'hexists' :function(Numberkey|Stringkey,Stringfield[,Functioncback]) :Object'hget' :function(Numberkey|Stringkey,Stringfield[,Functioncback]) :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(Numberkey|Stringkey[,Functioncback]) :Object'hincrby' :function(Numberkey|Stringkey,Stringfield,Numberinteger|Stringinteger[,Functioncback]) :Object'hincrbyfloat' :function(Numberkey|Stringkey,Stringfield,Numberfloat|Stringfloat[,Functioncback]) :Object'hkeys' :function(Numberkey|Stringkey[,Functioncback]) :Object'hlen' :function(Numberkey|Stringkey[,Functioncback]) :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(Numberkey|Stringkey,Stringfield|Arrayfields) :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(Numberkey|arraykey,Arrayfvalues|Objectfvalues[,Functioncback]) :Object'hset' :function(Numberkey|Stringkey,Stringfield,Numbervalue|Stringvalue[,Functioncback]) :Object'hsetnx' :function(Numberkey|Stringkey,Stringfield,Numbervalue|Stringvalue[,Functioncback]) :Object'hstrlen' :function(Numberkey|Stringkey,Stringfield[,Functioncback]){'hvals' :function(Numberkey|Stringkey[,Functioncback]) :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(Numberkey|Stringkey,Numbercursor|Stringcursor,Objectopt|Arrayargs[,Functioncback]) :Object
RedisHyperLogLog, 4 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'pfadd' :function(Numberkey|Stringkey,Stringchannel|Arraychannels[,Functioncback]) :Object'pfcount' :function(Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object'pfmerge' :function(Numberdest|Stringdest,Stringsource|Arraysources[,Functioncback]) :Object'pfselftest' :function([Functioncback]) :Object
RedisKeys, 24 commands.
NOTE: OBJECT is an empty parent command with 3 subcommands.
Arguments within [ ] are optional, '|' indicates multiple type for an argument.
'del' :function(Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object'dump' :function(Numberkey|Stringkey[,Functioncback]) :Object'exists' :function(Numberkey|Stringkey[,Functioncback]) :Object'expire' :function(Numberkey|Stringkey,Numberseconds[,Functioncback]) :Object'expireat' :function(Numberkey|Stringkey,Numberunixtime[,Functioncback]) :Object'keys' :function([Stringpattern[,Functioncback]]) :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(Numberkey|Stringkey,Arrayargs|Objectopt[,Functioncback]) :Object'move' :function(Numberkey|Stringkey,Stringdb|Numberdb[,Functioncback]) :Object'object' :{'encoding' :function(Numberkey|Stringkey[,Functioncback]) :Object'idletime' :function(Numberkey|Stringkey[,Functioncback]) :Object'refcount' :function(Numberkey|Stringkey[,Functioncback]) :Object}'persist' :function(Numberkey|Stringkey[,Functioncback]) :Object'pexpire' :function(Numberkey|Stringkey,Numbermillis[,Functioncback]) :Object'pexpireat' :function(Numberkey|Stringkey,Numberunixtime[,Functioncback]) :Object'pttl' :function(Numberkey|Stringkey[,Functioncback]) :Object'randomkey' :function([Functioncback]) :Object'rename' :function(Numberkey|Stringkey,Stringname|Numbername[,Functioncback]) :Object'renamenx' :function(Numberkey|Stringkey,Stringname|Numbername[,Functioncback]) :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(Numberkey|Stringkey,Numberttl,Bufferdata[,Functioncback]) :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(Numbercursor|Stringcursor,Objectopt|Arrayargs[,Functioncback]) :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(Numberkey|Stringkey,Objectopt|Arrayargs[,Functioncback]) :Object'touch' :function(Arraykeys[,Functioncback]) :Object'ttl' :function(Numberkey|Stringkey[,Functioncback]) :Object'type' :function(Numberkey|Stringkey[,Functioncback]) :Object
RedisLists, 17 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'blpop' :function(Numberkey|Stringkey,Numbertimeout|Stringtimeout[,Functioncback]) :Object'brpop' :function(Numberkey|Stringkey,Numbertimeout|Stringtimeout[,Functioncback]) :Object'brpoplpush' :function(Numbersrc|Stringsrc,Numberdest|Stringdest,Numbertimeout|Stringtimeout[,Functioncback]) :Object'lindex' :function(Numberkey|Stringkey,Numberindex|Stringindex[,Functioncback]) :Object'linsert' :function(Numberkey|Stringkey,Stringpos,Numberpivot|Stringpivot,Numberval|Stringval[,Functioncback]) :Object'llen' :function(Numberkey|Stringkey[,Functioncback]) :Object'lpop' :function(Numberkey|Stringkey[,Functioncback]) :Object'lpush' :function(Numbersrc|Stringsrc,Stringvalue|Arrayvalues[,Functioncback]) :Object'lpushx' :function(Numbersrc|Stringsrc,Stringvalue[,Functioncback]) :Object'lrange' :function(Numberkey|Stringkey,Numberstart|Stringstart,Numberstop|Stringstop[,Functioncback]) :Object'lrem' :function(Numberkey|Stringkey,Numbercount|Stringcount,Numberval|Stringval[,Functioncback]) :Object'lset' :function(Numberkey|Stringkey,Numberindex|Stringindex,Numberval|Stringval[,Functioncback]) :Object'ltrim' :function(Numberkey|Stringkey,Numberstart|Stringstart,Numberstop|Stringstop[,Functioncback]) :Object'rpop' :function(Numberkey|Stringkey[,Functioncback]) :Object'rpoplpush' :function(Numbersrc|Stringsrc,Numberdest|Stringdest[,Functioncback]) :Object'rpush' :function(Numbersrc|Stringsrc,Stringvalue|Arrayvalues[,Functioncback]) :Object'rpushx' :function(Numbersrc|Stringsrc,Numbervalue|Stringvalue[,Functioncback]) :Object
RedisPubSub, 6 commands.
NOTE: PUBSUB is an empty parent command with 3 subcommands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'publish' :function(Stringchannel,Stringmessage[,Functioncback]) :Object'pubsub' :{'channels' :function([Stringpattern[,Functioncback]]) :Object'numpat' :function([Functioncback]) :Object'numsub' :function(Stringchannel|Arraychannels[,Functioncback]) :Object}'psubscribe' :function(Stringpattern|Arraypatterns[,Functioncback]) :Object'punsubscribe' :function(Stringpattern|Arraypatterns[,Functioncback]) :Object'subscribe' :function(Numberchannel|Stringchannel|Arraychannels[,Functioncback]) :Object'unsubscribe' :function([Stringchannel|Arraychannels[,Functioncback]]) :Object
NOTE: to unsubscribe from all channels use null or [].
RedisScripting, 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(Stringscript,Arraykeys,Arrayargs[,Functioncback]) :Object/* * evalsha accepts 2 Arrays of keys and args. * * Original Redis command is: * * EVALSHA sha1 numkeys key [key ...] arg [arg ...] */'evalsha' :function(Stringsha,Arraykeys,Arrayargs[,Functioncback]) :Object'script' :{'exists' :function(Stringkey|Arraykeys[,Functioncback]) :Object'flush' :function([Functioncback]) :Object'kill' :function([Functioncback]) :Object'load' :function(Stringkey[,Functioncback]) :Object}
RedisServer, 31 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'bgrewriteaof' :function([Functioncback]) :Object'bgsave' :function([Functioncback]) :Object'client' :{'getname' :function([Functioncback]) :Object'kill' :function(Numberkey|Stringkey,Numberip|Stringip,Numberport|Stringport[,Functioncback]) :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([Functioncback]) :Object 'pause' :function(Numbermillis|Stringmillis[,Functioncback]) :Object 'reply' :function(Stringsw[,Functioncback]) :Object 'setname' :function(Numbername|Stringname[,Functioncback]) :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(Stringparam[,Functioncback]) :Object'resetstat' :function([Functioncback]) :Object'rewrite' :function([Functioncback]) :Object'set' :function(Stringparam,Numbervalue|Stringvalue[,Functioncback]) :Object}'command' :{/* * COMMAND LIST doesn't exists; it is s a placeholder for COMMAND. */'list' :function([Functioncback]) :Object'info' :function(Stringcmd|Arraylist[Functioncback]) :Object'getkeys' :function(Stringcmd|Arraycmd[,Functioncback]) :Object'count' :function([Functioncback]) :Object}'dbsize' :function([Functioncback]) :Object'debug' :{'object' :function(Numberkey|Stringkey[,Functioncback]) :Object'segfault' :function([Functioncback]) :Object}// Redis >= 4.0.0 added ASYNC option'flushall' :function([Booleanasync[,Functioncback]]) :Object// or legacy version that accepts only an optional callback'flushall' :function([Functioncback]) :Object// Redis >= 4.0.0 added ASYNC option'flushdb' :function([Booleanasync[,Functioncback]) :Object// or legacy version that accepts only an optional callback'flushdb' :function([Functioncback]) :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([Stringsection[,Functioncback]]) :Object'lastsave' :function([Functioncback]) :Object'monitor' :function([Functioncback]) :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([Functioncback]) :Object'save' :function([Functioncback]) :Object'shutdown' :function([Stringopt[,Functioncback]]) :Object'slaveof' :function(Stringhost,Numberport|Stringport[,Functioncback]) :Object'slowlog' :{'get' :function(Numberinteger|Stringinteger[,Functioncback]) :Object'len' :function([Functioncback]) :Object'reset' :function([Functioncback]) :Object}'sync' :function([Functioncback]) :Object'time' :function([Functioncback]) :Object
RedisSets, 15 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'sadd' :function(Numberkey|Stringkey,Stringmember|Arraymembers[,Functioncback]) :Object'scard' :function(Numberkey|Stringkey[,Functioncback]) :Object'sdiff' :function(Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object'sdiffstore' :function(Numberdest|Stringdest,Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object'sinter' :function(Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object'sinterstore' :function(Numberdest|Stringdest,Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object'sismember' :function(Numberkey|Stringkey,Stringmember|Arraymembers[,Functioncback]) :Object'smove' :function(Numbersrc|Stringsrc,Numberdest|Stringdest,Numbermember|Stringmember[,Functioncback]) :Object'smembers' :function(Numberkey|Stringkey[,Functioncback]) :Object'spop' :function(Numberkey|Stringkey[,Functioncback]) :Object'srandmember' :function(Numberkey|Stringkey,Numbercount|Stringcount[,Functioncback]) :Object'srem' :function(Numberkey|Stringkey,Numbermember|Stringmembers|Arraymembers[,Functioncback]) :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(Numberkey|Stringkey,Numbercursor|Stringcursor,Objectopt|Arrayargs[,Functioncback]) :Object'sunion' :function(Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object'sunionstore' :function(Numberdest|Stringdest,Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object
RedisSorted 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(Numberkey|stringkey,Arrayargs|Objectscores[,Functioncback]) :Object'zcard' :function(Numberkey|Stringkey[,Functioncback]) :Object'zcount' :function(Numberkey|Stringkey,Numbermin|Stringmin,Numbermax|Stringmax[,Functioncback]) :Object'zincrby' :function(Numberkey|Stringkey,Numberinteger|Stringinteger,Numbermember|Stringmember[,Functioncback]) :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(Numberdest|Stringdest,Arraykeys[,Arrayweights[,Stringaggregate[,Functioncback]]]) :Object'zlexcount' :function(Numberkey|Stringkey,Numbermin|Stringmin,Numbermax|Stringmax[,Functioncback]) :Object'zrange' :function(Numberkey|Stringkey,Numberstart|Stringstart,Numberstop|Stringstop[,Booleanwithscores[,Functioncback]]) :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(Numberkey|Stringkey,Numbermin|Stringmin,Numbermax|Stringmax[,Arraylimit[,Functioncback]]) :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(Numberkey|Stringkey,Numbermin|Stringmin,Numbermax|Stringmax[,Arraylimit[,Functioncback]]) :Object'zrangebyscore' :function(Numberkey|Stringkey,Numbermin|Stringmin,Numbermax|Stringmax[,Booleanwithscores[,Functioncback]]) :Object'zrank' :function(Numberkey|Stringkey,Numbermember|Stringmember[,Functioncback]) :Object'zrem' :function(Numberkey|Stringkey,Numbermember|Stringmember|Arraymembers[,Functioncback]) :Object'zremrangebylex' :function(Numberkey|Stringkey,Numbermin|Stringmin,Numbermax|Stringmax[,Functioncback]) :Object'zremrangebyrank' :function(Numberkey|Stringkey,Numberstart|Stringstart,Numberstop|Stringstop[,Functioncback]) :Object'zremrangebyscore' :function(Numberkey|Stringkey,Numbermin|Stringmin,Numbermax|Stringmax[,Functioncback]) :Object'zrevrank' :function(Numberkey|Stringkey,Numbermember|Stringmember[,Functioncback]) :Object'zrevrange' :function(Numberkey|Stringkey,Numberstart|Stringstart,Numberstop|Stringstop[,Booleanwithscores[,Functioncback]]) :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(Numberkey|Stringkey,Numberstart|Stringstart,Numberstop|Stringstop[,Booleanwithscores[,Arraylimit[,Functioncback]]]) :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(Numberkey|Stringkey,Numbercursor|Stringcursor,Objectopt|Arrayargs[,Functioncback]) :Object'zscore' :function(Numberkey|Stringkey,Numbermember|Stringmember[,Functioncback]) :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(Numberdest|Stringdest,Arraykeys[,Arrayweights[,Stringaggregate[,Functioncback]]]) :Object
RedisStrings, 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(Numberkey|Stringkey,Numbervalue|Stringvalue[,Functioncback]) :Object'bitcount' :function(Numberkey|Stringkey[,Arrayrange[,Functioncback]]) :Object'bittop' :{'and' :function(Numberdest|Stringdest,Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object'not' :function(Numberdest|Stringdest,Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object'or' :function(Numberdest|Stringdest,Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object'xor' :function(Numberdest|Stringdest,Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object}'bitpos' :function(Numberkey|Stringkey,Numberpos|Stringpos[,Arrayrange[,Functioncback]]) :Object'decr' :function(Numberkey|Stringkey[,Functioncback]) :Object'decrby' :function(Numberkey|Stringkey,Numberinteger|Stringinteger[,Functioncback]) :Object'get' :function(Numberkey|Stringkey[,Functioncback]) :Object'getbit' :function(Numberkey|Stringkey,Numberoffset|Stringoffset[,Functioncback]) :Object'getrange' :function(Numberkey|Stringkey,Stringstart|Numberstart,Stringend|Numberend[,Functioncback]) :Object'getset' :function(Numberkey|Stringkey,Numbervalue|Stringvalue[,Functioncback]) :Object'incr' :function(Numberkey|Stringkey[,Functioncback]) :Object'incrby' :function(Numberkey|Stringkey,Numberinteger|Stringinteger[,Functioncback]) :Object'incrbyfloat' :function(Numberkey|Stringkey,Stringfloat|Numberfloat[,Functioncback]) :Object'mget' :function(Numberkey|Stringkey|Arraykeys[,Functioncback]) :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(Arrayargs|Objectfvalues[,Functioncback]) :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(Arrayargs|Objectfvalues[,Functioncback]) :Object'psetex' :function(Numberkey|Stringkey,Stringmillis|Numbermillis,Numberval|Stringval[,Functioncback]) :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(Numberkey|Stringkey,Numberval|Stringval[,Arrayargs|Objectoptions[,Functioncback]]) :Object'setbit' :function(Numberkey|Stringkey,Numberoffset|Stringoffset,Numberval|Stringval[,Functioncback]) :Object'setex' :function(Numberkey|Stringkey,Numbersecs|Stringsecs,Numbervalue|Stringvalue[,Functioncback]) :Object'setnx' :function(Numberkey|Stringkey,Numbervalue|Stringvalue[,Functioncback]) :Object'setrange' :function(Numberstart|Stringstart,Numberoffset|Stringoffset,Numberval|Stringval[,Functioncback]) :Object'strlen' :function(Numberkey|Stringkey[,Functioncback]) :Object
RedisTransactions, 5 commands.
Arguments within [ ] are optional, '|' indicates multiple type for argument.
'discard' :function([Functioncback]) :Object'exec' :function([Functioncback]) :Object'multi' :function([Functioncback]) :Object'watch' :function(Numberkey|Stringkey|Arraykeys[,Functioncback]) :Object'unwatch' :function([Functioncback]) :Object
Copyright (c) 2013-present < Guglielmo Ferri :44gatti@gmail.com >
Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the'Software'), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:
The above copyright notice and this permission notice shall beincluded 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 OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANYCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
About
Σ Syllabus, a collection of helpers mix-ins to encode Redis commands, builded upon Sermone.