Jedis to JedisCluster migration for AWS Elastic Cache

77 views
Skip to first unread message

Rajkumar Patange

unread,
Jul 21, 2021, 10:07:41 AM7/21/21
to Jedis
Hi Team,
Need input regarding JedisCluster, our old implementation was using Jedis Client which had inbuilt support for Transaction and Scan, we are migrating to AWS Elastic Cache which means we need to shift to JedisCluster(https://javadoc.io/doc/redis.clients/jedis/latest/redis/clients/jedis/JedisCluster.html) I need some reference related to JedisCluster support for Transaction & SCAN.

Thank you

Sazzadul Hoque

unread,
Jul 28, 2021, 3:58:45 AM7/28/21
to jedis...@googlegroups.com
Hi Rajkumar Patange,

It is not possible to support Transaction in Cluster mode. But it is possible to do Transaction on a hashslot with very little extra work.

JedisCluster already supports SCAN by hashtag. Again, overall scan is not supported by Redis Cluster itself.

PS: Your email was sent to spam by Gmail.

--
You received this message because you are subscribed to the Google Groups "Jedis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jedis_redis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jedis_redis/63d874ed-6817-4da7-961b-1d8b9026600cn%40googlegroups.com.

Rajkumar Patange

unread,
Jul 28, 2021, 4:44:40 AM7/28/21
to Jedis
Thanks for confirmation. The transaction implemented below way : 
Jedis jedisNodeConnection= jedisCluster.getConnectionFromSlot(JedisClusterCRC16.getSlot(hashKey(key)));
jedisNodeConnection.watch(hashKey(key));
Transaction transaction = jedisNodeConnection.multi();
transaction.set(hashKey(key), String.valueOf(item));
transaction.exec();
jedisNodeConnection.unwatch();
jedisNodeConnection.close();
Let me know if there is any better way.

Sazzadul Hoque

unread,
Jul 28, 2021, 8:10:09 AM7/28/21
to jedis...@googlegroups.com
It's a good Transaction implementation.

My two cents:
- I don't see the necessity of Transaction for only one operation.
- UNWATCH is unnecessary after EXEC.

Rajkumar Patange

unread,
Jul 28, 2021, 8:14:35 AM7/28/21
to Jedis
Thanks. Removed unwatch.  Yes , the transaction is not required for one operation we have multiple operations this was an example snippet . 
Reply all
Reply to author
Forward
0 new messages