Java客户端来连接ElasticCache Redis的缓存节点节点、缓存、端来、客户

2023-09-12 00:11:24 作者:可爱污女的萌大叔

有没有办法通过提供节点端点连接到Redis的缓存集群节点? 哪个库我应该用这个?

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

此外,它的API应该使用从缓存中存储和检索的内容?

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

推荐答案

这要看情况。

您可以连接到Redis的群集节点上没有指挥调度到其他节点。你刚才应该确保,你访问由节点处理的关键。如果要连接到从确认,您的连接是在 READONLY 模式,否则奴隶将与 MOVED 。

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.

有大量的基于Java的Redis的客户端:

There are plenty of Java-based Redis Clients:

低电平

Jedis - 同步API 生菜 - 异步和同步API SRP JRedis Jedis - synchronous API Lettuce - async and sync API SRP JRedis

高级

春数据Redis的(使用Jedis,生菜和SRP为司机) Redisson - 基于旧的生菜叉 Spring Data Redis (uses Jedis, Lettuce and SRP as drivers) Redisson - based on the old lettuce fork

...等等。你可以找到的Java Redis的客户更COM prehensive列表中 http://redis.io/clients#java

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

你应该采取?哪些客户端

那么,这主要取决于你的需求。如果你需要只是一个客户的短期连接,那么也许Jedis是您正确的选择。如果你需要的灵活性,异步响应和定制codeCS,则生菜可能是你的朋友。

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.

如果你想处理Java集合,锁和更多的人,再看看春Redis的数据或Redisson。

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

你应该采取?哪些API

还取决于您的要求。 Redis的协议可能比memcached的协议,因为Redis的支持更多的数据结构更加灵活。

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

心连心,马克

 
精彩推荐