diff --git a/doc/AuthCommand.html b/doc/AuthCommand.html index a326a845..ff734a60 100644 --- a/doc/AuthCommand.html +++ b/doc/AuthCommand.html @@ -26,7 +26,7 @@
Request for authentication in a password protected Redis server.A Redis server can be instructed to require a password before to allow clientsto issue commands. This is done using the requirepass directive in theRedis configuration file.+ #sidebar ConnectionHandlingSidebar
Request for authentication in a password protected Redis server.A Redis server can be instructed to require a password before to allow clientsto issue commands. This is done using the requirepass directive in theRedis configuration file.
If the password given by the client is correct the server replies withan OK status code reply and starts accepting commands from the client.Otherwise an error is returned and the clients needs to try a new password.Note that for the high performance nature of Redis it is possible to trya lot of passwords in parallel in very short time, so make sure to generatea strong and very long password so that this attack is infeasible.
redis-benchmark
utility that simulates SETs/GETs done by N clients at the same time sending M total queries (it is similar to the Apache's ab
utility). Below you'll find the full output of the benchmark executed against a Linux box.+How Fast is Redis?
Redis includes theredis-benchmark
utility that simulates SETs/GETs done by N clients at the same time sending M total queries (it is similar to the Apache'sab
utility). Below you'll find the full output of the benchmark executed against a Linux box.
./redis-benchmark -n 100000 ====== SET ====== diff --git a/doc/BgsaveCommand.html b/doc/BgsaveCommand.html index 5fab9485..33468ae5 100644 --- a/doc/BgsaveCommand.html +++ b/doc/BgsaveCommand.html @@ -16,7 +16,7 @@BgsaveCommand
@@ -26,10 +26,10 @@-BGSAVE
+ #sidebar ControlCommandsSidebarBGSAVE
Save the DB in background. The OK code is immediately returned.Redis forks, the parent continues to server the clients, the childsaves the DB on disk then exit. A client my be able to check if theoperation succeeded using the LASTSAVE command.-Return value
Status code replySee also
- +Return value
Status code reply +
set a key to a string value
return the string value of the key
set a key to a string returning the old value of the key
multi-get, return the strings values of the keys
set a key to a string value if the key does not exist
set a multiple keys to multiple values in a single atomic operation
set a multiple keys to multiple values in a single atomic operation if none of the keys already exist
increment the integer value of key
increment the integer value of key by integer
decrement the integer value of key
decrement the integer value of key by integer
test if a key exists
delete a key
return the type of the value stored at key
return all the keys matching a given pattern
return a random key from the key space
rename the old key in the new one, destroing the newname key if it already exists
rename the old key in the new one, if the newname key does not already exist
return the number of keys in the current db
set a time to live in seconds on a key
get the time to live in seconds of a key
test if a key exists
delete a key
return the type of the value stored at key
return all the keys matching a given pattern
return a random key from the key space
rename the old key in the new one, destroing the newname key if it already exists
rename the old key in the new one, if the newname key does not already exist
return the number of keys in the current db
set a time to live in seconds on a key
get the time to live in seconds of a key
Select the DB having the specified index
Move the key from the currently selected DB to the DB having as index dbindex
Remove all the keys of the currently selected DB
Remove all the keys from all the databases
set a key to a string value
return the string value of the key
set a key to a string returning the old value of the key
multi-get, return the strings values of the keys
set a key to a string value if the key does not exist
set a multiple keys to multiple values in a single atomic operation
set a multiple keys to multiple values in a single atomic operation if none of the keys already exist
increment the integer value of key
increment the integer value of key by integer
decrement the integer value of key
decrement the integer value of key by integer
Append an element to the tail of the List value at key
Append an element to the head of the List value at key
Return the length of the List value at key
Return a range of elements from the List at key
Trim the list at key to the specified range of elements
Return the element at index position from the List at key
Set a new value as the element at index position of the List at key
Remove the first-N, last-N, or all the elements matching value from the List at key
Return and remove (atomically) the first element of the List at key
Return and remove (atomically) the last element of the List at key
Return and remove (atomically) the last element of the source List stored at _srckey_ and push the same element to the destination List stored at _dstkey_
Add the specified member to the Set value at key
Remove the specified member from the Set value at key
Remove and return (pop) a random element from the Set value at key
Move the specified member from one Set to another atomically
Return the number of elements (the cardinality) of the Set at key
Test if the specified value is a member of the Set at key
Return the intersection between the Sets stored at key1, key2, ..., keyN
Compute the intersection between the Sets stored at key1, key2, ..., keyN, and store the resulting Set at dstkey
Return the union between the Sets stored at key1, key2, ..., keyN
Compute the union between the Sets stored at key1, key2, ..., keyN, and store the resulting Set at dstkey
Return the difference between the Set stored at key1 and all the Sets key2, ..., keyN
Compute the difference between the Set key1 and all the Sets key2, ..., keyN, and store the resulting Set at dstkey
Return all the members of the Set value at key
Return a random member of the Set value at key
Add the specified member to the Set value at key or update the score if it already exist
Remove the specified member from the Set value at key
Return a range of elements from the sorted set at key
Return a range of elements from the sorted set at key, exactly like ZRANGE, but the sorted set is ordered in traversed in reverse order, from the greatest to the smallest score
Return all the elements with score >= min and score <= max (a range query) from the sorted set
Return the cardinality (number of elements) of the sorted set at key
Return the score associated with the specified element of the sorted set at key
Select the DB having the specified index
Move the key from the currently selected DB to the DB having as index dbindex
Remove all the keys of the currently selected DB
Remove all the keys from all the databases
Add the specified member to the Set value at key or update the score if it already exist
Remove the specified member from the Set value at key
Return a range of elements from the sorted set at key
Return a range of elements from the sorted set at key, exactly like ZRANGE, but the sorted set is ordered in traversed in reverse order, from the greatest to the smallest score
Return all the elements with score >= min and score <= max (a range query) from the sorted set
Return the cardinality (number of elements) of the sorted set at key
Return the score associated with the specified element of the sorted set at key
Remove all the elements with score >= min and score <= max from the sorted set
Sort a Set or a List accordingly to the specified parameters
Synchronously save the DB on disk
Asynchronously save the DB on disk
Return the UNIX time stamp of the last successfully saving of the dataset on disk
Synchronously save the DB on disk, then shutdown the server
Return the number of keys in the currently selected database.-
Return the number of keys in the currently selected database.+
Remove the specified keys. If a given key does not existno operation is performed for this key. The commnad returns the number ofkeys removed.
an integer greater than 0 if one or more keys were removed 0 if none of the specified key existed -
Test if the specified key exists. The command returns"0" if the key exists, otherwise "1" is returned.Note that even keys set with an empty string as value willreturn "1".
1 if the key exists. 0 if the key does not exist. -
Set a timeout on the specified key. After the timeout the key will beautomatically delete by the server. A key with an associated timeout issaid to be volatile in Redis terminology.
Voltile keys are stored on disk like the other keys, the timeout is persistenttoo like all the other aspects of the dataset. Saving a dataset containingthe dataset and stopping the server does not stop the flow of time as Redisregisters on disk when the key will no longer be available as Unix time, andnot the remaining seconds.@@ -57,8 +57,8 @@ OK
1: the timeout was set. 0: the timeout was not set since the key already has an associated timeout, or the key does not exist. -
RPUSH data to the computer_ID key
. Don't want to save more than 1000 log lines per computer? Just issue a LTRIM computer_ID 0 999
command to trim the list after every push.echo 1 > /proc/sys/vm/overcommit_memory
:)overcommit_memory
setting is set to zero fork will fail unless there is as much free RAM as required to really duplicate all the parent memory pages, with the result that if you have a Redis dataset of 3 GB and just 2 GB of free memory it will fail.overcommit_memory
to 1 says Linux to relax and perform the fork in a more optimistic allocation fashion, and this is indeed what you want for Redis.Delete all the keys of all the existing databases, not just the currently selected one. This command never fails.-
Delete all the keys of the currently selected DB. This command never fails.-
Get the value of the specified key. If the keydoes not exist the special value 'nil' is returned.If the value stored at key is not a string an erroris returned because GET can only handle string values.-
GETSET is an atomic set this value and return the old value command.Set key to the string value and return the old value stored at key.The string can't be longer than 1073741824 bytes (1 GB).
GETSET can be used together with INCR for counting with atomic reset whena given condition arises. For example a process may call INCR against thekey mycounter every time some event occurred, but from time totime we need to get the value of the counter and reset it to zero atomicallyusing GETSET mycounter 0
.
-Increment or decrement the number stored at key by one. If the key doesnot exist or contains a value of a wrong type, set the key to thevalue of "0" before to perform the increment or decrement operation.
INCRBY and DECRBY work just like INCR and DECR but instead toincrement/decrement by 1 the increment/decrement is integer.-
INCR commands are limited to 64 bit signed integers.+
The info command returns different information and statistics about the server in an format that's simple to parse by computers and easy to red by huamns.+ #sidebar ControlCommandsSidebar
The info command returns different information and statistics about the server in an format that's simple to parse by computers and easy to red by huamns.
edis_version:0.07 connected_clients:1 @@ -39,8 +39,6 @@ total_commands_processed:1 uptime_in_seconds:25 uptime_in_days:0All the fields are in the form
field:value
used_memory
is returned in bytes, and is the total number of bytes allocated by the program using malloc
.uptime_in_days
is redundant since the uptime in seconds contains already the full uptime information, this field is only mainly present for humans.changes_since_last_save
does not refer to the number of key changes, but to the number of operations that produced some kind of change in the dataset.+$ ./redis-cli set mykey "my binary safe value" +OK +$ ./redis-cli get mykey +my binary safe value +As you can see using the Set command and the Get command is trivial to set values to strings and have this strings returned back.
+$ ./redis-cli set counter 100 +OK +$ ./redis-cli incr counter +(integer) 101 +$ ./redis-cli incr counter +(integer) 102 +$ ./redis-cli incrby counter 10 +(integer) 112 +The INCR command parses the string value as an integer, increments it by one, and finally sets the obtained value as the new string value. There are other similar commands like INCRBY, DECR and DECRBY. Actually internally it's always the same command, acting in a slightly different way.
+$ ./redis-cli rpush messages "Hello how are you?" +OK +$ ./redis-cli rpush messages "Fine thanks. I'm having fun with Redis" +OK +$ ./redis-cli rpush messages "I should look into this NOSQL thing ASAP" +OK +$ ./redis-cli lrange messages 0 2 +1. Hello how are you? +2. Fine thanks. I'm having fun with Redis +3. I should look into this NOSQL thing ASAP +Note that LRANGE takes two indexes, the first and the last element of the range to return. Both the indexes can be negative to tell Redis to start to count for the end, so -1 is the last element, -2 is the penultimate element of the list, and so forth.
+$ ./redis-cli incr next.news.id +(integer) 1 +$ ./redis-cli set news:1:title "Redis is simple" +OK +$ ./redis-cli set news:1:url "http://code.google.com/p/redis" +OK +$ ./redis-cli lpush submitted.news 1 +OK +We obtained an unique incremental ID for our news object just incrementing a key, then used this ID to create the object setting a key for every field in the object. Finally the ID of the new object was pushed on the submitted.news list.
+$ ./redis-cli sadd myset 1 +(integer) 1 +$ ./redis-cli sadd myset 2 +(integer) 1 +$ ./redis-cli sadd myset 3 +(integer) 1 +$ ./redis-cli smembers myset +1. 3 +2. 1 +3. 2 +I added three elements to my set and told Redis to return back all the elements. As you can see they are not sorted.
+$ ./redis-cli sismember myset 3 +(integer) 1 +$ ./redis-cli sismember myset 30 +(integer) 0 +"3" is a member of the set, while "30" is not. Sets are very good in order to express relations between objects. For instance we can easily Redis Sets in order to implement tags.
+$ ./redis-cli sadd news:1000:tags 1 +(integer) 1 +$ ./redis-cli sadd news:1000:tags 2 +(integer) 1 +$ ./redis-cli sadd news:1000:tags 5 +(integer) 1 +$ ./redis-cli sadd news:1000:tags 77 +(integer) 1 +$ ./redis-cli sadd tag:1:objects 1000 +(integer) 1 +$ ./redis-cli sadd tag:2:objects 1000 +(integer) 1 +$ ./redis-cli sadd tag:5:objects 1000 +(integer) 1 +$ ./redis-cli sadd tag:77:objects 1000 +(integer) 1 +To get all the tags for a given object is trivial:
+$ ./redis-cli sinter tag:1:objects tag:2:objects tag:10:objects tag:27:objects +... no result in our dataset composed of just one object ;) ... +Look at the Command Reference to discover other Set related commands, there are a bunch of interesting one. Also make sure to check the SORT command as both Redis Sets and Lists are sortable.
+$ ./redis-cli zadd hackers 1940 "Alan Kay" +(integer) 1 +$ ./redis-cli zadd hackers 1953 "Richard Stallman" +(integer) 1 +$ ./redis-cli zadd hackers 1965 "Yukihiro Matsumoto" +(integer) 1 +$ ./redis-cli zadd hackers 1916 "Claude Shannon" +(integer) 1 +$ ./redis-cli zadd hackers 1969 "Linus Torvalds" +(integer) 1 +$ ./redis-cli zadd hackers 1912 "Alan Turing" +(integer) 1 +For sorted sets it's a joke to return these hackers sorted by their birth year because actually they are already sorted. Sorted sets are implemented via a dual-ported data structure containing both a skip list and an hash table, so every time we add an element Redis performs an O(log(N)) operation, that's good, but when we ask for sorted elements Redis does not have to do any work at all, it's already all sorted:
+$ ./redis-cli zrange hackers 0 -1 +1. Alan Turing +2. Claude Shannon +3. Alan Kay +4. Richard Stallman +5. Yukihiro Matsumoto +6. Linus Torvalds +Didn't know that Linus was younger than Yukihiro btw ;)
+$ ./redis-cli zrevrange hackers 0 -1 +1. Linus Torvalds +2. Yukihiro Matsumoto +3. Richard Stallman +4. Alan Kay +5. Claude Shannon +6. Alan Turing +A very important note, ZSets have just a "default" ordering but you are still free to call the SORT command against sorted sets to get a different ordering (but this time the server will waste CPU). An alternative for having multiple orders is to add every element in multiple sorted sets at the same time.
+$ ./redis-cli zrangebyscore hackers -inf 1950 +1. Alan Turing +2. Claude Shannon +3. Alan Kay +We asked Redis to return all the elements with a score between negative infinite and 1950 (both extremes are included).
+$ ./redis-cli zremrangebyscore hackers 1940 1960 +(integer) 2 +ZREMRANGEBYSCORE is not the best command name, but it can be very useful, and returns the number of removed elements.
Returns all the keys matching the glob-style pattern asspace separated strings. For example if you have in thedatabase the keys "foo" and "foobar" the command "KEYS foo*
"will return "foo foobar".
Note that while the time complexity for this operation is O(n)the constant times are pretty low. For example Redis runningon an entry level laptop can scan a 1 million keys databasein 40 milliseconds. Still it's better to consider this one ofthe slow commands that may ruin the DB performance if not usedwith care.Glob style patterns examples:
* haello will match hello and hallo, but not hilloUse \ to escape special chars if you want to match them verbatim.
* RANDOMKEY to get the name of a randomly selected key in O(1).
* haello will match hello and hallo, but not hilloUse \ to escape special chars if you want to match them verbatim.
Return the UNIX TIME of the last DB save executed with success.A client may check if a BGSAVE command succeeded reading the LASTSAVEvalue, then issuing a BGSAVE command and checking at regular intervalsevery N seconds if LASTSAVE changed.-
Return the specified element of the list stored at the specifiedkey. 0 is the first element, 1 the second and so on. Negative indexesare supported, for example -1 is the last element, -2 the penultimateand so on.
If the value stored at key is not of list type an error is returned.If the index is out of range an empty string is returned.
Note that even if the average time complexity is O(n) asking forthe first or the last element of the list is O(1).-
+LPUSH mylist a # now the list is "a" +LPUSH mylist b # now the list is "b","a" +RPUSH mylist c # now the list is "b","a","c" (RPUSH was used this time) ++The resulting list stored at mylist will contain the elements "b","a","c".
Return the length of the list stored at the specified key. If thekey does not exist zero is returned (the same behaviour as forempty lists). If the value stored at key is not a list an error is returned.
The length of the list. -
Atomically return and remove the first (LPOP) or last (RPOP) elementof the list. For example if the list contains the elements "a","b","c" LPOPwill return "a" and the list will become "b","c".
If the key does not exist or the list is already empty the specialvalue 'nil' is returned.-
Return the specified elements of the list stored at the specifiedkey. Start and end are zero-based indexes. 0 is the first elementof the list (the list head), 1 the next element and so on.
For example LRANGE foobar 0 2 will return the first three elementsof the list.
_start_ and end can also be negative numbers indicating offsetsfrom the end of the list. For example -1 is the last element ofthe list, -2 the penultimate element and so on.
Indexes out of range will not produce an error: if start is overthe end of the list, or start >
end, an empty list is returned.If end is over the end of the list Redis will threat it just likethe last element of the list.
-Remove the first count occurrences of the value element from the list.If count is zero all the elements are removed. If count is negativeelements are removed from tail to head, instead to go from head to tailthat is the normal behaviour. So for example LREM with count -2 and_hello_ as value to remove against the list (a,b,c,hello,x,hello,hello) willlave the list (a,b,c,hello,x). The number of removed elements is returnedas an integer, see below for more information about the returned value.Note that non existing keys are considered like empty lists by LREM, so LREMagainst non existing keys will always return 0.
The number of removed elements if the operation succeeded -
Set the list element at index (see LINDEX for information about the_index_ argument) with the new value. Out of range indexes willgenerate an error. Note that setting the first or last elements ofthe list is O(1).-
Trim an existing list so that it will contain only the specifiedrange of elements specified. Start and end are zero-based indexes.0 is the first element of the list (the list head), 1 the next elementand so on.
For example LTRIM foobar 0 2 will modify the list stored at foobarkey so that only the first three elements of the list will remain.
_start_ and end can also be negative numbers indicating offsetsfrom the end of the list. For example -1 is the last element ofthe list, -2 the penultimate element and so on.@@ -36,8 +36,8 @@ LPUSH mylist <someelement> LTRIM mylist 0 99
The above two commands will push elements in the list taking care thatthe list will not grow without limits. This is very useful when usingRedis to store logs for example. It is important to note that when usedin this way LTRIM is an O(1) operation because in the average casejust one element is removed from the tail of the list.-
Get the values of all the specified keys. If one or more keys dont existor is not of type String, a 'nil' value is returned instead of the valueof the specified key, but the operation never fails.
$ ./redis-cli set foo 1000 @@ -41,8 +41,8 @@ $ ./redis-cli mget foo bar nokey 2. 2000 3. (nil) $ -
MONITOR is a debugging command that outputs the whole sequence of commandsreceived by the Redis server. is very handy in order to understandwhat is happening into the database. This command is used directlyvia telnet.+ #sidebar ControlCommandsSidebar
MONITOR is a debugging command that outputs the whole sequence of commandsreceived by the Redis server. is very handy in order to understandwhat is happening into the database. This command is used directlyvia telnet.
% telnet 127.0.0.1 6379 Trying 127.0.0.1... @@ -52,8 +52,8 @@ set foo_a 5 hello
The ability to see all the requests processed by the server is useful in orderto spot bugs in the application both when using Redis as a database and asa distributed caching system.
In order to end a monitoring session just issue a QUIT command by hand.-
Move the specified key from the currently selected DB to the specifieddestination DB. Note that this command returns 1 only if the key wassuccessfully moved, and 0 if the target key was already there or if thesource key was not found at all, so it is possible to use MOVE as a lockingprimitive.
1 if the key was moved 0 if the key was not moved because already present on the target DB or was not found in the current DB. -
Set the the rispective keys to the rispective values. MSET will replace oldvalues with new values, while MSETNX will not perform any operation at alleven if just a single key already exists.
Because of this semantic MSETNX can be used in order to set different keysrepresenting different fields of an unique logic object in a way thatensures that either all the fields or none at all are set.@@ -34,7 +34,8 @@
1 if the all the keys were set 0 if no key was set (at least one key already existed) -
+ = Quick Start =
This quickstart is a five minutes howto on how to get started with Redis. For more information on Redis check Redis Documentation Index.Obtain the latest version
The latest stable source distribution of Redis can be obtained at this location as a tarball.$ wget http://redis.googlecode.com/files/redis-1.02.tar.gzThe unstable source code, with more features but not ready for production, can be downloaded using git:$ git clone git://github.com/antirez/redis.git @@ -57,18 +57,7 @@ firstvalue $ ./redis-cli lrange mylist 0 -1 1. thirdvalue 2. secondvalue -Lists (and Sets too) can be sorted:-./redis-cli sort mylist alpha -1. secondvalue -2. thirdvalue -And despite Redis doesn't have integers, you can do some math also:-$ ./redis-cli get mycounter -(nil) -$ ./redis-cli incr mycounter -1 -./redis-cli incr mycounter -2 -Further reading
Ask the server to silently close the connection.+ #sidebar ConnectionHandlingSidebar
Ask the server to silently close the connection.
slaveof 192.168.1.100 6379
. We provide a Replication Howto if you want to know more about this feature.Return a randomly selected key from the currently selected DB.-
Atomically renames the key oldkey to newkey. If the source anddestination name are the same an error is returned. If newkeyalready exists it is overwritten.-
Rename oldkey into newkey but fails if the destination key newkey already exists.
1 if the key was renamed 0 if the target key already exist -
Atomically return and remove the last (tail) element of the srckey list,and push the element as the first (head) element of the dstkey list. Forexample if the source list contains the elements "a","b","c" and thedestination list contains the elements "foo","bar" after an RPOPLPUSH commandthe content of the two lists will be "a","b" and "c","foo","bar".
If the key does not exist or the list is already empty the specialvalue 'nil' is returned. If the srckey and dstkey are the same theoperation is equivalent to removing the last element from the list and pusingit as first element of the list, so it's a "list rotation" command.
Redis lists are often used as queues in order to exchange messages betweendifferent programs. A program can add a message performing an LPUSH operationagainst a Redis list (we call this program a Producer), while another program(that we call Consumer) can process the messages performing an RPOP commandin order to start reading the messages from the oldest.
Unfortunately if a Consumer crashes just after an RPOP operation the messagegets lost. RPOPLPUSH solves this problem since the returned message isadded to another "backup" list. The Consumer can later remove the messagefrom the backup list using the LREM command when the message was correctlyprocessed.
Another process, called Helper, can monitor the "backup" list to check fortimed out entries to repush against the main queue.
Using RPOPPUSH with the same source and destination key a process canvisit all the elements of an N-elements List in O(N) without to transferthe full list from the server to the client in a single LRANGE operation.Note that a process can traverse the list even while other processesare actively RPUSHing against the list, and still no element will be skipped.-
Add the string value to the head (RPUSH) or tail (LPUSH) of the liststored at key. If the key does not exist an empty list is created just beforethe append operation. If the key exists but is not a List an erroris returned.-
Add the specified member to the set value stored at key. If memberis already a member of the set no operation is performed. If keydoes not exist a new set with the specified member as sole member iscrated. If the key exists but does not hold a set value an error isreturned.
1 if the new element was added 0 if the element was already a member of the set -
Save the DB on disk. The server hangs while the saving is notcompleted, no connection is served in the meanwhile. An OK codeis returned when the DB was fully stored in disk.-
Return the set cardinality (number of elements). If the key does notexist 0 is returned, like for empty sets.
the cardinality (number of elements) of the set as an integer. -
Return the members of a set resulting from the difference between the firstset provided and all the successive sets. Example:
key1 = x,a,b,c @@ -34,8 +34,8 @@ key2 = c key3 = a,d SDIFF key1,key2,key3 => x,b
Non existing keys are considered like empty sets.-
This commnad works exactly like SDIFF but instead of being returned the resulting set is sotred in dstkey.-
Select the DB with having the specified zero-based numeric index.For default every new client connection is automatically selectedto DB 0.-
Set the string value as value of the key.The string can't be longer than 1073741824 bytes (1 GB).-
SETNX works exactly like SET with the only difference thatif the key already exists no operation is performed.SETNX actually means "SET if Not eXists".
1 if the key was set 0 if the key was not set -
Stop all the clients, save the DB, then quit the server. This commandsmakes sure that the DB is switched off without the lost of any data.This is not guaranteed if the client uses simply "SAVE" and then"QUIT" because other clients may alter the DB data between the twocommands.-
Return the members of a set resulting from the intersection of all thesets hold at the specified keys. Like in LRANGE the result is sent tothe client as a multi-bulk reply (see the protocol specification formore information). If just a single key is specified, then this commandproduces the same result as SMEMBERS. Actually SMEMBERS is just syntaxsugar for SINTERSECT.+ #sidebar SetCommandsSidebar
Return the members of a set resulting from the intersection of all thesets hold at the specified keys. Like in LRANGE the result is sent tothe client as a multi-bulk reply (see the protocol specification formore information). If just a single key is specified, then this commandproduces the same result as SMEMBERS. Actually SMEMBERS is just syntaxsugar for SINTERSECT.
Non existing keys are considered like empty sets, so if one of the keys ismissing an empty set is returned (since the intersection with an emptyset always is an empty set).-
* SADD* SREM* SISMEMBER* SCARD* SMEMBERS* SINTERSTORE* SUNION* SUNIONSTORE* SMOVE+
This commnad works exactly like SINTER but instead of being returned the resulting set is sotred as _dstkey_.-
* SADD* SREM* SISMEMBER* SCARD* SMEMBERS* SINTER* SINTERSTORE* SMOVE+ #sidebar SetCommandsSidebar
This commnad works exactly like SINTER but instead of being returned the resulting set is sotred as dstkey.+
Return 1 if member is a member of the set stored at key, otherwise0 is returned.
1 if the element is a member of the set 0 if the element is not a member of the set OR if the key does not exist -
The SLAVEOF command can change the replication settings of a slave on the fly.If a Redis server is arleady acting as slave, the commandSLAVEOF NO ONE
will turn off the replicaiton turning the Redis server into a MASTER.In the proper formSLAVEOF hostname port
will make the server a slave of thespecific server listening at the specified hostname and port.
If a server is already a slave of some master, SLAVEOF hostname port
willstop the replication against the old server and start the synchrnonizationagainst the new one discarding the old dataset.
The form SLAVEOF no one
will stop replication turning the server into aMASTER but will not discard the replication. So if the old master stop workingit is possible to turn the slave into a master and set the application touse the new master in read/write. Later when the other Redis server will befixed it can be configured in order to work as slave.
-Return all the members (elements) of the set value stored at key. Thisis just syntax glue for SINTERSECT.-
Move the specifided member from the set at srckey to the set at dstkey.This operation is atomic, in every given moment the element will appear tobe in the source or destination set for accessing clients.
If the source set does not exist or does not contain the specified elementno operation is performed and zero is returned, otherwise the element isremoved from the source set and added to the destination set. On successone is returned, even if the element was already present in the destinationset.
An error is raised if the source or destination keys contain a non Set value.
1 if the element was moved 0 if the element was not found on the first set and no operation was performed -
[
BY pattern]
[
LIMIT start count]
[
GET pattern]
[
ASC|DESC]
[
ALPHA]
=
Sort the elements contained in the List or Set value at key. By defaultsorting is numeric with elements being compared as double precisionfloating point numbers. This is the simplest form of SORT.
SORT mylist @@ -52,8 +52,8 @@ SORT mylist BY weight_* GET object_*+Since Redis >= 1.1 it's possible to also GET the list elements itselfusing the special # pattern:SORT mylist BY weight_* GET object_* GET # -Return value
Multi bulk reply, specifically a list of sorted elements.See Also
-
Remove a random element from a Set returning it as return value.If the Set is empty or the key does not exist, a nil object is returned.+
The SRANDMEMBER command does a similar work butthe returned element is not removed from the Set.+
Return a random element from a Set, without removing the element. If the Set is empty or the key does not exist, a nil object is returned.+
The SPOP command does a similar work but the returned elementis popped (removed) from the Set.+
Remove the specified member from the set value stored at key. If_member_ was not a member of the set no operation is performed. If keydoes not hold a set value an error is returned.
1 if the new element was removed 0 if the new element was not a member of the set -
sds.c
(simple dynamic strings). This library caches the current length of the string, so to obtain the length of a Redis string is an O(1) operation (but currently there is no such STRLEN command. It will likely be added later).Return the members of a set resulting from the union of all thesets hold at the specified keys. Like in LRANGE the result is sent tothe client as a multi-bulk reply (see the protocol specification formore information). If just a single key is specified, then this commandproduces the same result as SMEMBERS.
Non existing keys are considered like empty sets.-
This commnad works exactly like SUNION but instead of being returned the resulting set is sotred as dstkey.-
The TTL command returns the remaining time to live in seconds of a key that has an EXPIRE set. This introspection capability allows a Redis client to check how many seconds a given key will continue to be part of the dataset. If the Key does not exists or does not have an associated expire, -1 is returned.-
The TTL command returns the remaining time to live in seconds of a key that has an EXPIRE set. This introspection capability allows a Redis client to check how many seconds a given key will continue to be part of the dataset. If the Key does not exists or does not have an associated expire, -1 is returned.+
Return the type of the value stored at key in form of astring. The type can be one of "none", "string", "list", "set"."none" is returned if the key does not exist.
"none" if the key does not exist diff --git a/doc/ZaddCommand.html b/doc/ZaddCommand.html index d798eb2b..fa4c8950 100644 --- a/doc/ZaddCommand.html +++ b/doc/ZaddCommand.html @@ -16,7 +16,7 @@-ZaddCommand: Contents
ZADD _key_ _score_ _member_ (Redis >
Return value
See also +ZaddCommand: Contents
ZADD _key_ _score_ _member_ (Redis >
Return valueZaddCommand
@@ -26,15 +26,14 @@-ZADD _key_ _score_ _member_ (Redis >
1.1) = + #sidebar SortedSetCommandsSidebarZADD _key_ _score_ _member_ (Redis >
1.1) = Time complexity O(log(N)) with N being the number of elements in the sorted setAdd the specified member having the specifeid score to the sortedset stored at key. If member is already a member of the sorted setthe score is updated, and the element reinserted in the right position toensure sorting. If key does not exist a new sorted set with the specified_member_ as sole member is crated. If the key exists but does not hold asorted set value an error is returned.The score value can be the string representation of a double precision floatingpoint number.-For an introduction to sorted sets check the Redis sorted sets page.+For an introduction to sorted sets check the Introduction to Redis data types page.Return value
Integer reply, specifically:1 if the new element was added 0 if the element was already a member of the sorted set and the score was updated -See also
- +
Return the sorted set cardinality (number of elements). If the key does notexist 0 is returned, like for empty sorted sets.
the cardinality (number of elements) of the set as an integer. -
Return the specified elements of the sorted set at the specifiedkey. The elements are considered sorted from the lowerest to the highestscore when using ZRANGE, and in the reverse order when using ZREVRANGE.Start and end are zero-based indexes. 0 is the first elementof the sorted set (the one with the lowerest score when using ZRANGE), 1the next element by score and so on.
_start_ and end can also be negative numbers indicating offsetsfrom the end of the sorted set. For example -1 is the last element ofthe sorted set, -2 the penultimate element and so on.
Indexes out of range will not produce an error: if start is overthe end of the sorted set, or start >
end, an empty list is returned.If end is over the end of the sorted set Redis will threat it just likethe last element of the sorted set.
-Return the all the elements in the sorted set at key with a score between_min_ and max (including elements with score equal to min or max).+ #sidebar SortedSetCommandsSidebar
Return the all the elements in the sorted set at key with a score between_min_ and max (including elements with score equal to min or max).
The elements having the same score are returned sorted lexicographically asASCII strings (this follows from a property of Redis sorted sets and does notinvolve further computation).-
Using the optional LIMIT it's possible to get only a range of the matchingelements in an SQL-alike way. Note that if offset is large the commandsneeds to traverse the list for offset elements and this adds up to theO(M) figure.+
Remove the specified member from the sorted set value stored at key. If_member_ was not a member of the set no operation is performed. If keydoes not not hold a set value an error is returned.
1 if the new element was removed 0 if the new element was not a member of the set -
Remove all the elements in the sorted set at key with a score between_min_ and max (including elements with score equal to min or max).+
Return the score of the specified element of the sorted set at key.If the specified element does not exist in the sorted set, or the keydoes not exist at all, a special 'nil' value is returned.
the score (a double precision floating point number) represented as string. -
<->
slave replication works.