redis主页上列出的java 客户端有JDBC-Redis JRedis Jedis三种,下面分别介绍三种客户端的优缺点及其他相关的工具.
| 支持redis版本 | 性能 | 维护 | 推荐 |
JDBC-Redis | not good | |||
JRedis | 1.2.n release 2.0.0 尚未release版本 | fast | ||
Jedis | 2.0.0 release | fast | actively developed | 推荐 |
JDBC-Redis
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.
Redis 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
spring wrapper
Spring provides a wrapper around both implementations(Jredis Jedis) 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);
spring nosql/cross-store
prototype implementation allowing entities to be stored in multiple types of data stores (i.e. JPA and Neo4j or JPA and Redis etc.)
JOhm
JOhm is a blazingly fast Object-Hash Mapping library for Java inspired by the awesome Ohm. The JOhm OHM is a modern-day avatar of the old ORM's like Hibernate with the difference being that we are not dealing with an RDBMS here but with a NoSQL rockstar.
homepage:https://github.com/xetorthio/johm
参考:
http://stackoverflow.com/questions/3047010/best-redis-library-for-java
https://github.com/xetorthio/johm