Spring Data Key-Value

org.springframework.data.keyvalue.redis.core
Interface RedisOperations<K,V>

All Known Implementing Classes:
RedisTemplate, StringRedisTemplate

public interface RedisOperations<K,V>

Interface that specified a basic set of Redis operations, implemented by RedisTemplate. Not often used but a useful option for extensibility and testability (as it can be easily mocked or stubbed).

Author:
Costin Leau

Method Summary
<HK,HV> BoundHashOperations<K,HK,HV>
boundHashOps(K key)
          Returns the operations performed on hash values bound to the given key.
 BoundListOperations<K,V> boundListOps(K key)
          Returns the operations performed on list values bound to the given key.
 BoundSetOperations<K,V> boundSetOps(K key)
          Returns the operations performed on set values bound to the given key.
 BoundValueOperations<K,V> boundValueOps(K key)
          Returns the operations performed on simple values (or Strings in Redis terminology) bound to the given key.
 BoundZSetOperations<K,V> boundZSetOps(K key)
          Returns the operations performed on zset values (also known as sorted sets) bound to the given key.
 void convertAndSend(String destination, Object message)
           
 void delete(Collection<K> key)
           
 void discard()
           
 Object exec()
           
<T> T
execute(RedisCallback<T> action)
          Executes the given action within a Redis connection.
<T> T
execute(SessionCallback<T> session)
          Executes a Redis session.
 Boolean expire(K key, long timeout, TimeUnit unit)
           
 Boolean expireAt(K key, Date date)
           
 Long getExpire(K key)
           
 Boolean hasKey(K key)
           
 Set<K> keys(K pattern)
           
 void multi()
          '
<HK,HV> HashOperations<K,HK,HV>
opsForHash()
          Returns the operations performed on hash values.
 ListOperations<K,V> opsForList()
          Returns the operations performed on list values.
 SetOperations<K,V> opsForSet()
          Returns the operations performed on set values.
 ValueOperations<K,V> opsForValue()
          Returns the operations performed on simple values (or Strings in Redis terminology).
 ZSetOperations<K,V> opsForZSet()
          Returns the operations performed on zset values (also known as sorted sets).
 void persist(K key)
           
 K randomKey()
           
 void rename(K oldKey, K newKey)
           
 Boolean renameIfAbsent(K oldKey, K newKey)
           
 List<V> sort(K key, SortParameters params)
           
 Long sort(K key, SortParameters params, K destination)
           
 DataType type(K key)
           
 void unwatch()
           
 void watch(Collection<K> keys)
           
 

Method Detail

execute

<T> T execute(RedisCallback<T> action)
Executes the given action within a Redis connection. Application exceptions thrown by the action object get propagated to the caller (can only be unchecked) whenever possible. Redis exceptions are transformed into appropriate DAO ones. Allows for returning a result object, that is a domain object or a collection of domain objects. Performs automatic serialization/deserialization for the given objects to and from binary data suitable for the Redis storage. Note: Callback code is not supposed to handle transactions itself! Use an appropriate transaction manager. Generally, callback code must not touch any Connection lifecycle methods, like close, to let the template do its work.

Type Parameters:
T - return type
Parameters:
action - callback object that specifies the Redis action
Returns:
a result object returned by the action or null

execute

<T> T execute(SessionCallback<T> session)
Executes a Redis session. Allows multiple operations to be executed in the same session enabling 'transactional' capabilities through multi() and watch(Collection) operations.

Type Parameters:
T - return type
Parameters:
session - session callback
Returns:
result object returned by the action or null

hasKey

Boolean hasKey(K key)

delete

void delete(Collection<K> key)

type

DataType type(K key)

keys

Set<K> keys(K pattern)

randomKey

K randomKey()

rename

void rename(K oldKey,
            K newKey)

renameIfAbsent

Boolean renameIfAbsent(K oldKey,
                       K newKey)

expire

Boolean expire(K key,
               long timeout,
               TimeUnit unit)

expireAt

Boolean expireAt(K key,
                 Date date)

persist

void persist(K key)

getExpire

Long getExpire(K key)

watch

void watch(Collection<K> keys)

unwatch

void unwatch()

multi

void multi()
'


discard

void discard()

exec

Object exec()

sort

List<V> sort(K key,
             SortParameters params)

sort

Long sort(K key,
          SortParameters params,
          K destination)

convertAndSend

void convertAndSend(String destination,
                    Object message)

opsForValue

ValueOperations<K,V> opsForValue()
Returns the operations performed on simple values (or Strings in Redis terminology).

Returns:
value operations

boundValueOps

BoundValueOperations<K,V> boundValueOps(K key)
Returns the operations performed on simple values (or Strings in Redis terminology) bound to the given key.

Parameters:
key - Redis key
Returns:
value operations bound to the given key

opsForList

ListOperations<K,V> opsForList()
Returns the operations performed on list values.

Returns:
list operations

boundListOps

BoundListOperations<K,V> boundListOps(K key)
Returns the operations performed on list values bound to the given key.

Parameters:
key - Redis key
Returns:
list operations bound to the given key

opsForSet

SetOperations<K,V> opsForSet()
Returns the operations performed on set values.

Returns:
set operations

boundSetOps

BoundSetOperations<K,V> boundSetOps(K key)
Returns the operations performed on set values bound to the given key.

Parameters:
key - Redis key
Returns:
set operations bound to the given key

opsForZSet

ZSetOperations<K,V> opsForZSet()
Returns the operations performed on zset values (also known as sorted sets).

Returns:
zset operations

boundZSetOps

BoundZSetOperations<K,V> boundZSetOps(K key)
Returns the operations performed on zset values (also known as sorted sets) bound to the given key.

Parameters:
key - Redis key
Returns:
zset operations bound to the given key.

opsForHash

<HK,HV> HashOperations<K,HK,HV> opsForHash()
Returns the operations performed on hash values.

Type Parameters:
HK - hash key (or field) type
HV - hash value type
Returns:
hash operations

boundHashOps

<HK,HV> BoundHashOperations<K,HK,HV> boundHashOps(K key)
Returns the operations performed on hash values bound to the given key.

Type Parameters:
HK - hash key (or field) type
HV - hash value type
Parameters:
key - Redis key
Returns:
hash operations bound to the given key.

Spring Data Key-Value

Copyright © 2010-2011 SpringSource. All Rights Reserved.