资讯专栏INFORMATION COLUMN

Redis - Redisson vs Jedis

阿罗 / 1118人阅读

摘要:较底层,可塑性强,要自己实现。省的自己去实现轮子。总结另外有中文文档。。。

Additional dependencies

Jedis requires Apache Commons Pool 2 for connection-pooling.

Redisson requires Netty, the JCache API and Project Reactor as basic dependencies.

Programming model

Jedis is a low-level driver exposing Redis API as Java method calls:

Jedis jedis = …;

jedis.set("key", "value");

List values = jedis.mget("key", "key2", "key3");

Redisson is a high-level client, each call invokes one or more Redis calls, some of them are implemented with Lua (Redis "Scripting").

Redisson redisson = …

RMap map = redisson.getMap("my-map"); // implement java.util.Map

map.put("key", "value");

map.containsKey("key");

map.get("key");

Scalability

Jedis uses blocking I/O and method calls are synchronous. Your program flow is required to wait until I/O is handled by the sockets. There"s no asynchronous (Future, CompletableFuture) or reactive support (Reactive Streams Publisher). Jedis client instances are not thread-safe hence they require connection-pooling (Jedis-instance per calling thread).

Redisson uses non-blocking I/O and an event-driven communication layer with netty. Connections are pooled, but the API itself is thread-safe and requires fewer resources. you can even operate on a single connection. That"s the most efficient way when working with Redis.

Client implementation

Jedis gives you full control over the commands you invoke and the resulting behavior. 较底层,可塑性强,high-level features要自己实现。

Using Redissons high-level features means that you can use objects without the need of knowing they are backed by Redis (Map, List, Set, …)。省的自己去实现轮子。

总结:Redisson supports all the things Jedis supports and provides read strategies for Master/Slave setups, has improved support for AWS ElastiCache. 另外有中文文档。。。

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/68477.html

相关文章

  • 基于Redis实现分布式锁

    摘要:本篇博客将介绍第二种方式,基于的实现分布式锁。总结本文主要介绍了如何使用代码正确实现分布式锁,对于加锁和解锁也分别给出了两个比较经典的错误示例。其实想要通过实现分布式锁并不难,只要保证能满足可靠性里的四个条件。 前言 分布式锁一般有三种实现方式:1.数据库乐观锁;2、基于Redis的分布式锁;3.基于Zookeeper的分布式锁。本篇博客将介绍第二种方式,基于Redis的实现分布式锁。...

    jonh_felix 评论0 收藏0
  • JAVA面试题(36)

    摘要:请输入代码本文首发于的博客转载请注明出处和有哪些区别参考博客优点轻量简洁支持连接池支持事务缺点不支持读写分离文档支持不足官方推荐优点采用非阻塞支持异步请求支持连接池支持支持读写分离以及读负载平衡可与集成文档支持充足怎么保证缓存和数据库数据的 请输入代码    本文首发于cartoon的博客    转载请注明出处:https://cartoonyu.github.io/c... Je...

    neu 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<