-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Supports Multi Key commands to JedisCluster (revised of #673) #687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supports Multi Key commands to JedisCluster (revised of #673) #687
Conversation
* New interfaces introduced (copy existing interfaces and remove some commands) * there're some commands that doesn't seems to compatible with Redis Cluster * remove commands from BinaryJedisCluster & JedisCluster * Add some util (KeyMergeUtil), exception (related CROSSSLOT) classes * Add runWithAnyNode() to JedisClusterCommand * some of commands (ex. publish/subscribe) doesn't need to run into specific node
|
@vishnusaran @ReedR95 @xetorthio @marcosnils |
|
@HeartSaVioR I'm reviewing this right now. You'll get my feedback soon. |
|
@marcosnils It seems that you forgot to review this. :) |
|
Yeah, I blocked thinking about some alternatives but I finally couldn't come up with a better solution. Between today and tomorrow I'll be done with this. |
|
@marcosnils You can share your alternative idea to realize. :) Btw, we got duplicate methods from Jedis, ShardedJedis, PipelineBase, JedisCluster. |
|
@marcosnils How about merging it to 'cluster-revised' branch when we cannot find better solution right now? Do you need much time to consider better solution? |
Conflicts: src/main/java/redis/clients/jedis/BinaryJedisCluster.java src/main/java/redis/clients/jedis/JedisCluster.java
|
Upmerged to recent cluster-revised. |
|
I would like to really thank you guys for contributing in this open source project. |
|
@rupatel Hello. In addition, AFAIK multi key operations are allowed as long as all keys belong to same "slot". One more thing, if you're expecting Redis to process at real-time, do not use "keys". One user requests "count keys in slot" command to Redis Google Group. Hope this helps. |
|
@HeartSaVioR Also currently I am converting serialized java object to base64 string and then storing it to the redis server. |
|
@rupatel Here's some example about scan with cluster. Redis "scan" command just shows only keys which are served from "specific" instance. antirez will (I think he should) add scan command supporting cluster environment before releasing 3.0.0 GA. |
|
@rupatel And Jedis is a blazingly "small" Redis Java client. |
|
@HeartSaVioR |
|
@HeartSaVioR |
|
@rupatel I can only say you have to make your own, or post an issue to Redis about supporting scan inside of slot. JedisCluster has a feature about returning connection which serves a slot based on current slot cache, but it's hidden and I cannot say exposing it will be a good idea. ps. Currently Redis Cluster is not for production environment. It's BETA, and not even RC yet. |
|
@rupatel I think it's not related to support multi key for now. |
|
OK,I will wait for redis to be production ready so that client don't need to implement it separately. Thanks for all your efforts. |
|
I'm curious that we can reuse current interfaces, and throw UnsupportedOperationException if method seems not fit to Redis Cluster. |
|
I believe that it's better to have new interfaces for
|
|
Since we're in progress of reviewing #671, it should be included to cluster-revised branch. |
Conflicts: src/main/java/redis/clients/jedis/BinaryJedisCluster.java src/main/java/redis/clients/jedis/JedisCluster.java
|
I'll merge this to cluster-revised branch to prepare reviewing. |
Supports Multi Key commands to JedisCluster (revised of #673)
|
@rupatel ,for example this{foo}.bar1 and another{foo}.bar2 are guaranteed to be in the same hash slot, and I want get all keys like '{foo}.xxx', but there is no jedisCluster function like 'keys', so you have idea or some jedis solutions now ? Because of your Q&A above, could you give me some suggestions? |
|
Hey, We have to wait until they implement and place this feature in new release. Other option is to implement feature, I tried by using one of the api they had exposed to fetch the slot in which the current pattern is stored, but it is not a good design to iterate all nodes in cluster and fetch the keys since we need to handle failover and other cases. So I have not yet cracked the problem, if you find any solution please let me know. From:"Guocai He" notifications@github.com @rupatel ,for example this{foo}.bar1 and another{foo}.bar2 are guaranteed to be in the same hash slot, and I want get all keys like '{foo}.xxx', but there is no jedisCluster function like 'keys', so you have idea or some jedis solutions now ? Because of your Q&A above, could you give me some suggestion? — |
(It's revised PR of #673.)
Hello.
As supporting Redis Cluster work, I implemented Cluster multi key commands based on previous interfaces.
During implementing, I found that some commands are fine with Redis, but maybe some commands are not fine with Redis Cluster.
(Actually there're no documentation from Redis describing cluster-able commands.)
So I removed some suspicious commands from interface, and introduced new interfaces for Jedis Cluster.
(Please let me know when you think something is wrong.)
Below is the commands I removed from previous interfaces.
BinaryJedisClusterCommands (copied from BinaryCommands)
List<byte[]> blpop(byte[] arg);
List<byte[]> brpop(byte[] arg);
Long move(byte[] key, int dbIndex);
MultiKeyBinaryJedisClusterCommands (copied from MultiKeyBinaryCommands)
List<byte[]> blpop(byte[]... args);
List<byte[]> brpop(byte[]... args);
Set<byte[]> keys(byte[] pattern);
String watch(byte[]... keys);
String unwatch();
byte[] randomBinaryKey();
JedisClusterCommands (copied from JedisCommands)
List blpop(String arg);
List brpop(String arg);
Long move(String key, int dbIndex);
ScanResult<Map.Entry<String, String>> hscan(final String key, int cursor);
ScanResult sscan(final String key, int cursor);
ScanResult zscan(final String key, int cursor);
MultiKeyJedisClusterCommands (copied from MultiKeyCommands)
String watch(String... keys);
String unwatch();
String randomKey();
ScanResult scan(int cursor);
ScanResult scan(final String cursor);
Set keys(String pattern);
List blpop(String... args);
List brpop(String... args);
And I introduce some utils and exception, you can find it from commit log.
Please review and comment so that this PR goes to cluster-revised.
Thanks!