|
CommandReference
We moved to Redis.io!Redis home moved to http://redis.io, please visit our new home. |
► Sign in to add a comment
|
Search
|
|
CommandReference
We moved to Redis.io!Redis home moved to http://redis.io, please visit our new home. |
The Lists and Sets commands are fantastic!
Got one question: is there a lock command like "ACQUIRELOCK db1", "RELEASELOCK db1"?
This is very important for multiple data manipulations and every programming language and database supports it,
java got "synchronized" syntax, python got "thread.allocate_lock().acquire()", even php which does not support thread got "sem_acquire()".
In my project, we are using 2 languages, java and php, we used the mysql's "LOCK TABLES" instead the languages' locks.
If Redis got a support for this, or you have a good alternative way to do this. I would try Redis in my next project.
Thanks for the good work!
The "EXISTS" command cannot do what LOCK can do. Sometimes 2 different threads may call the "EXISTS" command at the same time, both returned the result "not exists" then both call the command "SET" to store the value, that's what exactly the php example "Retwis" register.php did (register.php used "GET" command but it's the same). I know that's only a example, and that can be fixed using php's own "sem_acquire()", I know, but now you are doing the cloud things, you cannot use a single language's lock on a single machine. Right? I suggest Redis bring 2 different level locks: the database lock and the key lock.
Now I figured out a way, use "SETNX" to acquire a lock, then after the manipulation, clear the lock. Is it the best way?
@occmailbox: Hello! The idea is that you can mount locking free algorithms on top of the atomic operation Redis provides. This is most of the times the best way to do things. Otherwise you can implement locking using SETNX or RENAMENX or other atomic primitives. Please post your specific problem on the Redis google group for more information. Almost all the times there is a locking free way to do stuff. Btw after Redis 1.0-stable release I plan to add locking primitives (that are not about keys or the whole DB but just about "tokens", so what a given token is really locking is up to your application). Ciao, Salvatore.
The best way to do lock-free updates would be to have an equivalent to memcache CAS, a check and set operation. The client gets the old value and a cookie (the cookie can be the old value itself, or some last-modified timestamp or a version number). Then they compute the new value, and ask the server to perform a check and set. Either the server sets the value, or it has changed and the server returns a status code indicating no change was done. In which case, the client retries, starting at the GET stage.
Synopsis: CAS KEY NEW_VALUE COOKIE
Sets key to new value if it wasn't modified since COOKIE.
I think there is a typo in the section SUNION. I believe the sentence ending "then this command produces the same result as SELEMENTS" should actually read "then this command produces the same result as SMEMBERS".
I don't understand where is LDEL command or something similar?
I think it should be better if add a EXPIRE command to DB, to let the whole db cache data expired
to support Map in the future?
I don't see any practical benefit of having SCARD and LLEN as separate commands. Proposal: similar to SORT, which works for both sets and lists, unite them in one (for example, LEN).
I echo Shein's question, where is LDEL command or similar?
@acharnock: it's not needed as DEL is already a vararg. DEL x y z ...
Is there a plan to support the memcache protocol? This one looks pretty close to me.
Hello nova77: no plans to support the memcached protocol. Redis has tons of features more, and a number of client libraries already implemented for many languages.
Is the command list a reflection of what commands are available in the development version or stable released version ?
@Bulkan: in every man page of commands requiring Redis > 1.0 it's specified what version is needed.
For completeness, shouldn't PING be added (NB: Shouldn't JRedis return a boolean?)
RFE: intersection of scored sets , which sums the scores of intersecting items. Also version of the command to write the result to another scored set.
Are there any plans to support "mincr" for multiple atomic increments?
@peer.oded: You're probably looking for INCRBY.
Please, can you annotate the commands with the version needed? Hashes seem to need >1.2.x...
Redis is a good idea..... Fast db systems need central-like directory server things.
Redis is a good idea..... Fast db systems need central-like directory server things.
This is pretty awesome, gotta say. Having said that, here's a functionality gap that cropped up while working on my pew pew space game: there is no non-destructive copy or move, so far as I can see. I'd like to be able to copy the value of a key to a new key, across DBs for bonus points, without having to worry about the actual content. I'm doing it right now in code, but it's cumbersome for anything other than strings, and probably slower than need be (I've not tried it with big datasets yet). Or - maybe there's a clever way to do this that I missed? (Why? I'm using DBs as a poor-man's transaction - I set a busy flag for the client, copy the DB, do my work, copy it back, unset busy - and if something blows up halfway thru my work, I don't end up with an inconsistent DB).
SORT is very powerful command when used with "GET pattern" but what if i don't need sorting? If some list, set or just string value holds part of key name of another value and is already sorted in necessary order (or produced from previous SORT call)? Is any way to do the same as SORT? E.g. list A contains values 4,7,1,3 and I need to get key_4, key_7, key_1, key_3 in that order? Such feature is also very good for SUNION/SINTER/SDIFF to avoid storing result in some new key (even when result is stored, I cannot get what I need if I don't need sorting (because don't want additional overhead), but just need names of set members for building key names).
Is there plans to address boolean data type. In fact, just storing a key without value, and accessing it with EXIST. I know it's already possible with value = 1 but my question could make sense if a optimized memory structure can be use to store it...
Thanks for your work, it's a way to open mind and find new way to address our requirements
"ZRANK key member Return the rank (or index) or member" must be changed to "ZRANK key member Return the rank (or index) OF member" and similar for ZREVRANK
Their are a few typos. How does one edit this?
I think I caught all the typos. Post any others you find please.
I think that the sorted sets are very powerful for managing priority queues, but it lacks a lot of useful commands which regular sets have, like SMOVE, SPOP etc.
Is there a way I can multi get keys with the key created at (or expires at timestamp if expiry is set) timestamp? What I need is TTL like method, but for multiple keys in one atomic operation.
There is no parameter for AUTH in the list. It should be 'password'.
Thanks, all set on the AUTH fix.
Is it possible to do a SUNION or SINTERSECTION on a set of keys, pass the result of this directly to the MGET command and then return the result of the MGET command?
This would save tremendous amounts of network traffic, when doing set operations on indexes with the intention to return the objects represented by the results of these set operations.
One could just pass in a reference to the indexes, and then have the objects returned in one step.
Some 'crazy' ideas. New commands in capital letters:
Conditionals:
IF operand_type_1 operand_1 operator operand_type_2 operand_2 THEN
ELSEoperand_type_1,operand_type_2 -> ["key","value","list"...] operator -> ["=",">","<",">=","<=","<>","!=","in","not in",...]
block -> single command or:
BEGIN
ENDBEGINPROCEDURE proc_name args ENDPROCEDURE
CALL proc_name args
Example 1:
IF key mykey1 = value "xx" THEN BEGIN
END ELSE BEGIN ENDExample 2:
BEGINPROCEDURE myswap key1 key2
ENDPROCEDURECALL myswap mykey1 mykey2 CALL myswap mykey2 mykey3
REDIS as a virtual machine - wow!
ZRANGE doesn't mention the WITHSCORES option which is annoying when you're sat there wondering how on earth to do that without calling ZSCORE on each member.
I need, given a string key value, to get the next/previous key according to the sorting order. Is it possible? Thanks.
HSETNX is missing from "Commands operating on hashes"
A suggestion for this page -- the "Commands operating on string values" section is kind of confusing because it lumps strings and integers together. It should probably be split into "Commands operating on string values" and "Commands operating on integer values".
BRPOPLPUSH is missing the timeout parameter