The official Redis homepage lists JDBC-Redis and JRedis. What are the advantages / disadvantages of each ? Are there any other options ?
7 Answers
You can use also Jedis, which is also in the official Redis clients page. It is compatible with the latest version of Redis.
Update
As of June 2012, Jedis is the Java client library recommended by the Redis official page.
-
8You could try [Redisson](https://github.com/mrniko/redisson), it implements distributed and scalable Java data structures on top of Redis server. Use familiar Java data structures with power of Redis. – Nikita Koksharov Jan 11 '14 at 15:23
-
1
-
What you think about lettuce?It's also recommented by Official Redis client page – melfore Feb 24 '16 at 18:59
-
3 ["recommended" Redis clients for Java](https://redis.io/clients#java) now: Jedis, lettuce, Redisson. – chrisjleu Apr 04 '17 at 15:43
Both Jedis and JRedis are being actively developed. I personally use Jedis since it seems to be more actively developed.
Spring provides a wrapper around both implementations and they're providing serialization/deserialization, amongst other things:
Person p = new Person("Joe", "Trader", 33);
template.convertAndSet("trader:1", p);
Person samePerson = template.getAndConvert("trader:1", Person.class);
Assert.assertEquals(p, samePerson);
http://git.springsource.org/spring-data/spring-keyvalue-redis/
UPDATE Spring Data now added support for a 3rd library called rjc (Redis Java Client) -- I don't know what the pros/cons for it are, though.

- 5,388
- 1
- 37
- 64
Jedis is a very good client. I have used jedis to make some performance test against redis. 50 clients, 1m requests completed in 20 seconds(on a old intel 2core 2.6g machine, 100m network). I believe the performance can be much higher if I can use 1000m network to do the test.

- 839
- 7
- 10
An easier solution is to not worry about working at the lowest level but use an Object Hash Mapper (OHM) like JOhm instead. JOhm lets users decorate their existing objects with familiar annotations to allow persistence to Redis without any invasive code changes. It does not even need any external configuration. You can think of the OHM as a NoSQL counterpart to the ORM of RDBMS.
JOhm is hosted here

- 124,656
- 32
- 289
- 307

- 397
- 4
- 4
-
Sorry but I would call JOhm a poor mans redis JPA implementation. It essentially requires that you define the structure of your complex objects with annotations. This begs the question of why you are trying to store structured data in a "NoSQL" database in the first place. Also it's not been updated in 6 years. – Phil Feb 01 '17 at 23:37
just an update: it seems jredis is not that active anymore, jedis however is going strong and had some great features implemented recently, it s also the same developer of JOhm.
extract from their readme on github:
Ok.. so what can I do with Jedis? [...]
Transactions
Pipelining
Publish/Subscribe
Persistence
control commands
Remote server control commands
Connection pooling
Sharding (MD5, MurmureHash)
Key-tags for sharding
Sharding with pipelining
I was using jredis until recently on half a dozen of projects, moved them all to jedis in no time, without surprises.

- 367
- 3
- 6
JDBC-Redis is just a JDBC wrapper for JRedis database.
If you plan on using your code with different back-ends then JDBC is a good way to go. NOTE: It is not a complete JDBC implementation and the NOSQL will bleed through.
If you are going to stay with Redis then I would suggest using the API, which will give you more flexibility. Use a DAO layer pattern to encapsulate your DB Access and down the road that is all you will need to change.

- 24,113
- 5
- 60
- 79
-
2Redis syntax is completely different from standard SQL so using JDBC doesn't help encapsulating different back-ends as you suggest: I would have to write new queries anyway... – muriloq Jun 16 '10 at 14:00
-
@muriloq - but the mechanical acquiring and releasing resources is standard. – Romain Hippeau Jun 16 '10 at 14:24
-
Actually JRedis is a client for Redis just as JDBC-Redis is a "connector/client" for Redis. JDBC-Redis must be missing pretty much all SQL related interfaces which makes it sound a bit pointless to me, unless I've missed something... – Phil Feb 02 '17 at 00:02