My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
CommandReference  
Updated Dec 21, 2010 by anti...@gmail.com

We moved to Redis.io!

Redis home moved to http://redis.io, please visit our new home.

Comment by occmail...@gmail.com, Apr 29, 2009

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!

Comment by occmail...@gmail.com, Apr 29, 2009

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.

Comment by occmail...@gmail.com, Apr 30, 2009

Now I figured out a way, use "SETNX" to acquire a lock, then after the manipulation, clear the lock. Is it the best way?

Comment by project member anti...@gmail.com, May 1, 2009

@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.

Comment by tobu...@gmail.com, May 1, 2009

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.

Comment by wong.ed...@gmail.com, Jul 24, 2009

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".

Comment by shein.ar...@gmail.com, Jul 29, 2009

I don't understand where is LDEL command or something similar?

Comment by zze...@163.com, Sep 16, 2009

I think it should be better if add a EXPIRE command to DB, to let the whole db cache data expired

Comment by zze...@163.com, Sep 16, 2009

to support Map in the future?

Comment by biruk...@gmail.com, Sep 28, 2009

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).

Comment by acharnock, Oct 19, 2009

I echo Shein's question, where is LDEL command or similar?

Comment by project member anti...@gmail.com, Oct 20, 2009

@acharnock: it's not needed as DEL is already a vararg. DEL x y z ...

Comment by nov...@gmail.com, Oct 22, 2009

Is there a plan to support the memcache protocol? This one looks pretty close to me.

Comment by project member anti...@gmail.com, Oct 22, 2009

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.

Comment by Bul...@gmail.com, Oct 24, 2009

Is the command list a reflection of what commands are available in the development version or stable released version ?

Comment by project member anti...@gmail.com, Nov 13, 2009

@Bulkan: in every man page of commands requiring Redis > 1.0 it's specified what version is needed.

Comment by alexgen...@gmail.com, Dec 5, 2009

For completeness, shouldn't PING be added (NB: Shouldn't JRedis return a boolean?)

Comment by dr.marc....@gmail.com, Feb 26, 2010

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.

Comment by peer.o...@gmail.com, Mar 11, 2010

Are there any plans to support "mincr" for multiple atomic increments?

Comment by jeethu...@gmail.com, Mar 18, 2010

@peer.oded: You're probably looking for INCRBY.

Comment by adam.sko...@gmail.com, Apr 12, 2010

Please, can you annotate the commands with the version needed? Hashes seem to need >1.2.x...

Comment by mtthwkfm...@gmail.com, Apr 30, 2010

Redis is a good idea..... Fast db systems need central-like directory server things.

Comment by mtthwkfm...@gmail.com, Apr 30, 2010

Redis is a good idea..... Fast db systems need central-like directory server things.

Comment by bort...@gmail.com, May 6, 2010

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).

Comment by yurasfro...@gmail.com, May 8, 2010

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).

Comment by erwan.pi...@gmail.com, May 10, 2010

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

Comment by yurasfro...@gmail.com, May 10, 2010

"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

Comment by kristopo...@gmail.com, Jul 16, 2010

Their are a few typos. How does one edit this?

Comment by project member michaelr...@gmail.com, Jul 16, 2010

I think I caught all the typos. Post any others you find please.

Comment by hers...@gmail.com, Jul 28, 2010

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.

Comment by sharie...@gmail.com, Aug 3, 2010

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.

Comment by dvsoftw...@gmail.com, Aug 12, 2010

There is no parameter for AUTH in the list. It should be 'password'.

Comment by project member michaelr...@gmail.com, Aug 22, 2010

Thanks, all set on the AUTH fix.

Comment by jorangr...@gmail.com, Sep 8, 2010

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.

Comment by qyl...@gmail.com, Oct 28, 2010

Some 'crazy' ideas. New commands in capital letters:

Conditionals:

IF operand_type_1 operand_1 operator operand_type_2 operand_2 THEN

block
ELSE
block

operand_type_1,operand_type_2 -> ["key","value","list"...] operator -> ["=",">","<",">=","<=","<>","!=","in","not in",...]

block -> single command or:

BEGIN

command command command ...
END

BEGINPROCEDURE proc_name args ENDPROCEDURE

CALL proc_name args

Example 1:

IF key mykey1 = value "xx" THEN BEGIN

SET mykey2 "yy" INCR mykey3
END ELSE BEGIN
SET mykey2 "zz" DECR mykey3
END

Example 2:

BEGINPROCEDURE myswap key1 key2

SET myswap_temp key1 SET key1 key2 SET key2 myswap_temp INCR myswap_cnt
ENDPROCEDURE

CALL myswap mykey1 mykey2 CALL myswap mykey2 mykey3

REDIS as a virtual machine - wow!

Comment by zimpenf...@gmail.com, Oct 30, 2010

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.

Comment by dima.kof...@gmail.com, Nov 23, 2010

I need, given a string key value, to get the next/previous key according to the sorting order. Is it possible? Thanks.

Comment by jedschm...@gmail.com, Nov 24, 2010

HSETNX is missing from "Commands operating on hashes"

Comment by RoySmith...@gmail.com, Nov 30, 2010

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".

Comment by seppo0010, Dec 18, 2010

BRPOPLPUSH is missing the timeout parameter


Sign in to add a comment
Powered by Google Project Hosting