public interface RedisOperations<K,V>
RedisTemplate
. Not often used but a
useful option for extensibility and testability (as it can be easily mocked or stubbed).Modifier and Type | Method and Description |
---|---|
<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 |
delete(K key) |
void |
discard() |
byte[] |
dump(K key) |
List<Object> |
exec() |
List<Object> |
exec(RedisSerializer<?> valueSerializer)
Execute a transaction, using the provided
RedisSerializer to deserialize any results that are byte[]s or
Collections of byte[]s. |
<T> T |
execute(RedisCallback<T> action)
Executes the given action within a Redis connection.
|
<T> T |
execute(RedisScript<T> script,
List<K> keys,
Object... args)
Executes the given
RedisScript |
<T> T |
execute(RedisScript<T> script,
RedisSerializer<?> argsSerializer,
RedisSerializer<T> resultSerializer,
List<K> keys,
Object... args)
Executes the given
RedisScript , using the provided RedisSerializer s to serialize the script
arguments and result. |
<T> T |
execute(SessionCallback<T> session)
Executes a Redis session.
|
List<Object> |
executePipelined(RedisCallback<?> action)
Executes the given action object on a pipelined connection, returning the results.
|
List<Object> |
executePipelined(RedisCallback<?> action,
RedisSerializer<?> resultSerializer)
Executes the given action object on a pipelined connection, returning the results using a dedicated serializer.
|
List<Object> |
executePipelined(SessionCallback<?> session)
Executes the given Redis session on a pipelined connection.
|
List<Object> |
executePipelined(SessionCallback<?> session,
RedisSerializer<?> resultSerializer)
Executes the given Redis session on a pipelined connection, returning the results using a dedicated serializer.
|
Boolean |
expire(K key,
long timeout,
TimeUnit unit) |
Boolean |
expireAt(K key,
Date date) |
List<RedisClientInfo> |
getClientList()
/** Request information and statistics about connected clients.
|
Long |
getExpire(K key) |
Long |
getExpire(K key,
TimeUnit timeUnit) |
RedisSerializer<?> |
getHashKeySerializer() |
RedisSerializer<?> |
getHashValueSerializer() |
RedisSerializer<?> |
getKeySerializer() |
RedisSerializer<?> |
getValueSerializer() |
Boolean |
hasKey(K key) |
Set<K> |
keys(K pattern) |
void |
killClient(String host,
int port)
Closes a given client connection identified by ip:port given in
client . |
Boolean |
move(K key,
int dbIndex) |
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).
|
Boolean |
persist(K key) |
K |
randomKey() |
void |
rename(K oldKey,
K newKey) |
Boolean |
renameIfAbsent(K oldKey,
K newKey) |
void |
restore(K key,
byte[] value,
long timeToLive,
TimeUnit unit) |
void |
slaveOf(String host,
int port)
Change redis replication setting to new master.
|
void |
slaveOfNoOne()
Change server into master.
|
List<V> |
sort(SortQuery<K> query) |
<T,S> List<T> |
sort(SortQuery<K> query,
BulkMapper<T,S> bulkMapper,
RedisSerializer<S> resultSerializer) |
<T> List<T> |
sort(SortQuery<K> query,
BulkMapper<T,V> bulkMapper) |
Long |
sort(SortQuery<K> query,
K storeKey) |
<T> List<T> |
sort(SortQuery<K> query,
RedisSerializer<T> resultSerializer) |
DataType |
type(K key) |
void |
unwatch() |
void |
watch(Collection<K> keys) |
void |
watch(K keys) |
<T> T execute(RedisCallback<T> action)
T
- return typeaction
- callback object that specifies the Redis action<T> T execute(SessionCallback<T> session)
multi()
and watch(Collection)
operations.T
- return typesession
- session callbackList<Object> executePipelined(RedisCallback<?> action)
action
- callback object to executeList<Object> executePipelined(RedisCallback<?> action, RedisSerializer<?> resultSerializer)
action
- callback object to executeresultSerializer
- The Serializer to use for individual values or Collections of values. If any returned
values are hashes, this serializer will be used to deserialize both the key and valueList<Object> executePipelined(SessionCallback<?> session)
session
- Session callbackList<Object> executePipelined(SessionCallback<?> session, RedisSerializer<?> resultSerializer)
session
- Session callbackresultSerializer
- <T> T execute(RedisScript<T> script, List<K> keys, Object... args)
RedisScript
script
- The script to executekeys
- Any keys that need to be passed to the scriptargs
- Any args that need to be passed to the scriptRedisScript.getResultType()
is null, likely indicating a
throw-away status reply (i.e. "OK")<T> T execute(RedisScript<T> script, RedisSerializer<?> argsSerializer, RedisSerializer<T> resultSerializer, List<K> keys, Object... args)
RedisScript
, using the provided RedisSerializer
s to serialize the script
arguments and result.script
- The script to executeargsSerializer
- The RedisSerializer
to use for serializing argsresultSerializer
- The RedisSerializer
to use for serializing the script return valuekeys
- Any keys that need to be passed to the scriptargs
- Any args that need to be passed to the scriptRedisScript.getResultType()
is null, likely indicating a
throw-away status reply (i.e. "OK")void delete(K key)
void delete(Collection<K> key)
K randomKey()
byte[] dump(K key)
void watch(K keys)
void watch(Collection<K> keys)
void unwatch()
void multi()
void discard()
List<RedisClientInfo> getClientList()
List
of RedisClientInfo
objects.List<Object> exec(RedisSerializer<?> valueSerializer)
RedisSerializer
to deserialize any results that are byte[]s or
Collections of byte[]s. If a result is a Map, the provided RedisSerializer
will be used for both the keys
and values. Other result types (Long, Boolean, etc) are left as-is in the converted results. Tuple results are
automatically converted to TypedTuples.valueSerializer
- The RedisSerializer
to use for deserializing the results of transaction execValueOperations<K,V> opsForValue()
BoundValueOperations<K,V> boundValueOps(K key)
key
- Redis keyListOperations<K,V> opsForList()
BoundListOperations<K,V> boundListOps(K key)
key
- Redis keySetOperations<K,V> opsForSet()
BoundSetOperations<K,V> boundSetOps(K key)
key
- Redis keyZSetOperations<K,V> opsForZSet()
BoundZSetOperations<K,V> boundZSetOps(K key)
key
- Redis key<HK,HV> HashOperations<K,HK,HV> opsForHash()
HK
- hash key (or field) typeHV
- hash value type<HK,HV> BoundHashOperations<K,HK,HV> boundHashOps(K key)
HK
- hash key (or field) typeHV
- hash value typekey
- Redis key<T> List<T> sort(SortQuery<K> query, RedisSerializer<T> resultSerializer)
<T> List<T> sort(SortQuery<K> query, BulkMapper<T,V> bulkMapper)
<T,S> List<T> sort(SortQuery<K> query, BulkMapper<T,S> bulkMapper, RedisSerializer<S> resultSerializer)
RedisSerializer<?> getValueSerializer()
RedisSerializer<?> getKeySerializer()
RedisSerializer<?> getHashKeySerializer()
RedisSerializer<?> getHashValueSerializer()
void killClient(String host, int port)
client
.host
- of connection to close.port
- of connection to closevoid slaveOf(String host, int port)
host
- port
- void slaveOfNoOne()
Copyright © 2015 Pivotal Software, Inc.. All rights reserved.