Java客户端来连接ElasticCache Redis的缓存节点 [英] Java Client to connect ElasticCache Redis Cache Node

查看:431
本文介绍了Java客户端来连接ElasticCache Redis的缓存节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过提供节点端点连接到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 - synchronous API
  • Lettuce - async and sync API
  • SRP
  • JRedis

高级

  • 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.

心连心,马克

这篇关于Java客户端来连接ElasticCache Redis的缓存节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆