Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Client to connect ElasticCache Redis Cache Node

Is there a way to connect to the Redis Cache Cluster Node by providing the Node endpoint? Which library should I use for this?

Also, which API should I use to store and retrieve contents from the Cache?

like image 400
Anand Avatar asked Aug 31 '26 17:08

Anand


1 Answers

In short

It depends.

Explanation

You can connect to Redis Cluster nodes without command dispatching to other nodes. You just should make sure, that you access keys that are handled by the node. If you are connecting to a slave make sure, that your connection is in READONLY mode, otherwise the slave will respond with MOVED.

There are plenty of Java-based Redis Clients:

Low Level

  • Jedis - synchronous API
  • Lettuce - async and sync API
  • SRP
  • JRedis

High Level

  • Spring Data Redis (uses Jedis, Lettuce and SRP as drivers)
  • Redisson

...and many more. You can find a more comprehensive list of Java Redis Clients at http://redis.io/clients#java

Which client should you take?

Well, this depends mostly on your requirements. If you need "just a client" for short-lived connections, then perhaps Jedis is the right choice for you. If you need flexibility, async responses and custom codecs, then lettuce might be your friend.

If you want to deal with Java Collections, Locks and many more, then take a look on Spring Data Redis or Redisson.

Which API should you take?

Depends also on your requirements. The Redis protocol might be more flexible than the memcached protocol since Redis supports more data structures.

HTH, Mark

like image 184
mp911de Avatar answered Sep 03 '26 08:09

mp911de



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!