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. 另外有中文文档。。。


重构地球
68 声望4 粉丝

rust-zero