Redis - Redisson vs Jedis
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<String> 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. 另外有中文文档。。。
相关推荐
zzdadexiaoha 2020-06-28
koushr 2020-06-11
camhan 2020-05-26
soyo 2020-05-04
王道革 2020-04-11
isHooky 2020-04-10
sunzxh 2020-03-23
oZaoHua 2020-03-04
憧憬 2019-12-29
middleware0 2019-11-07
xiemanR 2018-11-08
尹小鱼 2018-10-08
枫叶上的雨露 2017-05-23
yztezhl 2018-10-08
buaashang 2017-06-10
有梦就能飞 2019-06-28
凌风郎少 2019-06-28
lankk的魔法书札 2019-06-28