lua scripts on Redis Cluster

427 views
Skip to first unread message

Oleg Ruchovets

unread,
Apr 10, 2014, 12:29:50 AM4/10/14
to redi...@googlegroups.com
Hi All.
   Can lua script can / will be able to executed on Redis Cluster?

Thanks
Oleg.

Marc Gravell

unread,
Apr 10, 2014, 4:59:05 AM4/10/14
to redi...@googlegroups.com

Yes, that works. But: you should ensure that you use the keys argument correctly, passing any keys in as arguments. If the script uses multiple keys, you should use { / } to ensure that all the keys are in the same slot.

Marc

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Oleg Ruchovets

unread,
Apr 10, 2014, 11:42:52 PM4/10/14
to redi...@googlegroups.com
OK , Thank you Marc for the answer. 

We just planning to port out solution to the Redis cluster and we didn't work with the cluster so far.

Suppose we have multiple nodes Redis cluster. 

We are passing 2 keys to the Lua script.

 Keys could be on the different instances.
( by the way what is the meaning of REDIS SLOT)?

Will this be feasible to process 2 keys using lua?
   
Thanks
Oleg.

Marc Gravell

unread,
Apr 11, 2014, 4:09:21 AM4/11/14
to redi...@googlegroups.com

By "slot", I mean: in cluster, each key is hashed and modulo applied to produce an integer in a given range (0-16K). This is the "slot". The hash algorithm is deterministic, so the same key will always produce the same slot. Each server owns a pool of slots. In a simple 4 server case, they might each own 4k slots. Because the slots allocation can change (manually, not currently automatically - although that would be an awesome v3.something feature), your apps can't really rely on which slots are adjacent. But to help with your scenario, you can use "hash tags". Meaning: if you know that (for example) you want to talk multi-key about data about a customer, the rather than "/cust/123/balance" and "/cust/123/recent" you can use "{/cust/123}/balance" and "{/cust/123}/recent". The addition of braces means the the hash algorithm for both is now based on just "/cust/123". This means they will always hash to the same slot, so **now** you can use multi-key operations including scripts

HeartSaVioR

unread,
Apr 12, 2014, 10:22:06 PM4/12/14
to redi...@googlegroups.com
tl.dr : No, you can't.
You can't even do this with Redis Cluster if your keys are same Redis instance, but not same slot.
Redis Cluster will complain CROSSSLOT, if Redis Cluster doesn't have a bug.

If you wish to know what slot is, go get it Marc's explanation, or read Redis Cluster specification.
(I strongly suggest you read specification : http://redis.io/topics/cluster-spec)

2014년 4월 11일 금요일 오후 12시 42분 52초 UTC+9, Oleg Ruchovets 님의 말:
Reply all
Reply to author
Forward
0 new messages