diff --git a/src/docbkx/reference/redis.xml b/src/docbkx/reference/redis.xml index feb1e718e..55a1b4e1a 100644 --- a/src/docbkx/reference/redis.xml +++ b/src/docbkx/reference/redis.xml @@ -46,6 +46,98 @@
Connecting to Redis + + One of the first tasks when using Redis and Spring is to connect to the store through the IoC container. To do that, a Java connector (or binding) is required; + currently SDKV has support for Jedis and JRedis. No matter the library one chooses, there only one set of SDKV API that one needs to use that behaves consistently + across all connectors, namely the org.springframework.data.keyvalue.redis.connection package and its + RedisConnection and RedisConnectionFactory interfaces for working respectively for retrieving active + connection to Redis. + +
+ <interfacename>RedisConnection</interfacename> and <interfacename>RedisConnectionFactory</interfacename> + + RedisConnection provides the building block for Redis communication as it handles the communication with the Redis back-end. + It also automatically translates the underlying connecting library exceptions to Spring's consistent DAO exception + hierarchy so one can switch the connectors + without any code changes as the operation semantics remain the same. + + For the corner cases where the native library API is required, RedisConnection provides a dedicated method + getNativeConnection which returns the raw, underlying object used for communication. + + Active RedisConnection are created through RedisConnectionFactory. In addition, the factories act as + PersistenceExceptionTranslator meaning once declared, allow one to do transparent exception translation for example through the use of the + @Repository annotation and AOP. For more information see the dedicated + section in Spring Framework documentation. + + Depending on the underlying configuration, the factory can return a new connection or an existing connection (in case a pool is used). +
+ + The easiest way to work with a RedisConnectionFactory is to configure the appropriate connector through the IoC container and + inject it into the using class. + + + Connector features + + Unfortunately, currently, not connectors support all of Redis features - in particular JRedis does not have support for hashes yet though this is currently being worked on. + When invoking a method on the Connection API that is unsupported by the underlying library, a UnsupportedOperationException + is thrown. + This situation is likely to be fixed in the future, as the various connectors mature. + + + +
+ Configuring Jedis connector + + Jedis is one of the connectors supported by the Key Value module through the + org.springframework.data.keyvalue.redis.connection.jedis package. In its simples form, the Jedis configuration looks as follow: + + + + + + +]]> + + For intense use however, one might want to enable connection pooling or set a certain host or password: + + + + + +]]> + +
+ +
+ Configuring JRedis connector + + JRedis is another popular, open-source connector supported by SDKV through the + org.springframework.data.keyvalue.redis.connection.jredis package. + Since JRedis itself does not support (yet) Redis 2.x commands, SDKV uses an updated fork available + here. + + A typical JRedis configuration can looks like this: + + + + + +]]> +
+