[redis] cluster and multi set operations

793 views
Skip to first unread message

jason.桂林

unread,
Mar 4, 2012, 2:46:18 PM3/4/12
to redi...@googlegroups.com
commands like ZINTERSTORE, ZUNIONSTORE, SINTER, SUNION, which operate multi Set, if we are using cluster, and we are those keys are not on same server, will it lead problems, maybe slow or error?

for example, I want to remove item from set ua:inbox which item is belong to set ub:sendbox, 

Shall I using ZINTERSTORE, or I wrote a program or a lua script, loop items and remove it one by one, which is better ?  

--
Best regards,

Jason Green
桂林


jason.桂林

unread,
Mar 4, 2012, 3:09:29 PM3/4/12
to redi...@googlegroups.com
Oh, sorry, ZINTERSTORE is not remove a set but keep a set, I mean something like SDIFFSTORE, but there is no ZDIFFSTORE command.

I can only remove it one by one for a sorted set, right?

2012/3/5 jason.桂林 <gui...@gmail.com>

Josiah Carlson

unread,
Mar 4, 2012, 3:23:20 PM3/4/12
to redi...@googlegroups.com
Redis cluster does not allow you to intersect, union, or difference
sets or zsets that are not on the same node.

Using scripting doesn't help, because the script must be run on the
same Redis as all of the keys it is accessing.

You would have to implement it by hand outside of Redis.

Regards,
- Josiah

> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to
> redis-db+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/redis-db?hl=en.

jason.桂林

unread,
Mar 4, 2012, 4:03:39 PM3/4/12
to redi...@googlegroups.com
 because the script must be run on the
same Redis as all of the keys it is accessing.

This rule make all what I am coding can't work on cluster, even it can pass single machine test.

You mean this script won't work, because I can't assuming `KEYS[1]` and it's `ref` is on the same machine.

local a = redis.call('hget', KEYS[1], 'ref');
local b = redis.call('get', a);
return b

jason.桂林

unread,
Mar 4, 2012, 4:12:25 PM3/4/12
to redi...@googlegroups.com
Additional, does MULTI and EXEC need on same Redis? Does MULTI and EXEC increase perfermance of executing multi command than send command one by one

2012/3/5 jason.桂林 <gui...@gmail.com>

Josiah Carlson

unread,
Mar 4, 2012, 5:18:54 PM3/4/12
to redi...@googlegroups.com
Both KEYS[1] and 'a' must be on the same instance if you are using scripting.

- Josiah

Josiah Carlson

unread,
Mar 4, 2012, 5:24:40 PM3/4/12
to redi...@googlegroups.com
MULTI and EXEC only makes sense when run against a single Redis
instance. Since a cluster is not a single instance, it only makes
sense when running against a single member of the cluster.

MULTI/EXEC have never claimed to improve performance in the single
machine case. You may be confusing it with "pipelining",
http://redis.io/topics/pipelining , where many clients have MULTI/EXEC
transactions use pipelining. But you can usually use pipelining
without MULTI/EXEC, but again, a pipeline only makes sense against a
single Redis instance. You can have pipelines against multiple Redis
instances, but I'm don't believe existing clients support that, and I
don't believe that they will support that.

Regards,
- Josiah

Reply all
Reply to author
Forward
0 new messages