From b6cfd1ce9c652b48852e838a1a908b2dd1cb935a Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Mon, 13 Dec 2010 12:23:30 +0200 Subject: [PATCH] + add template docs --- src/docbkx/reference/redis.xml | 93 +++++++++++++++++++++++++++------- 1 file changed, 76 insertions(+), 17 deletions(-) diff --git a/src/docbkx/reference/redis.xml b/src/docbkx/reference/redis.xml index 42cdaa201..2088d582d 100644 --- a/src/docbkx/reference/redis.xml +++ b/src/docbkx/reference/redis.xml @@ -138,6 +138,14 @@ ]]> As one can note, the configuration is quite similar to the Jedis one. + + Currently, JRedis does not have support for binary keys. This forces the JredisConnection to perform encoding internally + (through base64 schema). In practice, this means it's safe to read/write arbitrary data however + the Redis key stored values will differ from the decoded ones, even in the simplest cases, since everything (no matter the format) is encoded. This will not be + the case for Redis values. + This issue is currently being addressed in the JRedis project and once fixed, will be incorporated by Spring Data Redis. + + @@ -145,24 +153,25 @@
Working with Objects through <classname>RedisTemplate</classname> - Most users are likely to use RedisTemplate and its coresponding package org.springframework.data.keyvalue.redis.core. + Most users are likely to use RedisTemplate and its coresponding package org.springframework.data.keyvalue.redis.core - the + template is in fact the central class of the Redis module due to its rich feature set. The template offers a high-level abstraction for Redis interaction - while RedisConnection offer low level methods that accept and return binary values (byte arrays), the template takes care of serialization and connection management, freeing the user from dealing with such details. Moreover, the template provides operations views (following the grouping from Redis command reference) that offer rich, generified interfaces for working against a certain type or certain key (through the KeyBound interfaces) as described below: - +
Operational views - - - + + + Interface - Redis description + Description @@ -170,55 +179,105 @@ - ValueOperations + ValueOperations Redis string (or value) operations - ListOperations + ListOperations Redis list operations - SetOperations + SetOperations Redis set operations - ZSetOperations + ZSetOperations Redis zset (or sorted set) operations - HashOperations + HashOperations Redis hash operations - BoundValueOperations + BoundValueOperations Redis string (or value) key bound operations - BoundListOperations + BoundListOperations Redis list key bound operations - BoundSetOperations + BoundSetOperations Redis set key bound operations - BoundZSetOperations + BoundZSetOperations Redis zset (or sorted set) key bound operations - BoundHashOperations + BoundHashOperations Redis hash key bound operations
+ Once configured, the template is thread-safe and can be reused across multiple instances. + + Out of the box, RedisTemplate uses a Java-based serializer for most of its operations. This means that any object written or read by the template will be + serializer/deserialized through Java. The serialization mechanism can be easily changed on the template and the Redis module offers several implementations available in the + org.springframework.data.keyvalue.redis.serializer package. + + Since it's quite the keys and values stored in Redis can be java.lang.String, the Redis modules provides StringRedisTemplate, + a convenient provides a one-stop solution for intensive operations operations. In addition to be bound to String keys, the template uses the + StringRedisSerializer underneath which means the stored keys and values are human readable (assuming the same encoding is used both in Redis and your code). + For example: + + + + + + + + + + ... +]]> + + + As with the other Spring templates, RedisTemplate and StringRedisTemplate allow the developer to talk directly to Redis through + the RedisCallback interface: this gives complete control to the developer as it talks directly to the RedisConnection. + + + () { + + public Object doInRedis(RedisConnection connection) throws DataAccessException { + Long size = connection.dbSize(); + ... + } + }); +}]]>
- Support Services + Support Classes
\ No newline at end of file