public class RedisKeyValueAdapter extends org.springframework.data.keyvalue.core.AbstractKeyValueAdapter implements org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<RedisKeyspaceEvent>
KeyValueAdapter implementation. Uses binary codec to read/write data from/to Redis. Objects
are stored in a Redis Hash using the value of RedisHash, the KeyspaceConfiguration or just
Class.getName() as a prefix.
@RedisHash("persons")
class Person {
@Id String id;
String name;
}
prefix ID
| |
V V
hgetall persons:5d67b7e1-8640-4475-beeb-c666fab4c0e5
1) id
2) 5d67b7e1-8640-4475-beeb-c666fab4c0e5
3) name
4) Rand al'Thor
KeyValueAdapter is not intended to store simple types such as String values.
Please use RedisTemplate for this purpose.| Modifier and Type | Class and Description |
|---|---|
static class |
RedisKeyValueAdapter.EnableKeyspaceEvents |
| Modifier | Constructor and Description |
|---|---|
protected |
RedisKeyValueAdapter()
Default constructor.
|
|
RedisKeyValueAdapter(RedisOperations<?,?> redisOps)
|
|
RedisKeyValueAdapter(RedisOperations<?,?> redisOps,
RedisConverter redisConverter)
Creates new
RedisKeyValueAdapter with specific RedisConverter. |
|
RedisKeyValueAdapter(RedisOperations<?,?> redisOps,
RedisMappingContext mappingContext)
Creates new
RedisKeyValueAdapter with default CustomConversions. |
|
RedisKeyValueAdapter(RedisOperations<?,?> redisOps,
RedisMappingContext mappingContext,
CustomConversions customConversions)
Creates new
RedisKeyValueAdapter. |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
void |
clear() |
boolean |
contains(Serializable id,
Serializable keyspace) |
long |
count(Serializable keyspace) |
byte[] |
createKey(String keyspace,
String id) |
Object |
delete(Serializable id,
Serializable keyspace) |
<T> T |
delete(Serializable id,
Serializable keyspace,
Class<T> type) |
void |
deleteAllOf(Serializable keyspace) |
void |
destroy() |
org.springframework.data.util.CloseableIterator<Map.Entry<Serializable,Object>> |
entries(Serializable keyspace) |
<T> T |
execute(RedisCallback<T> callback)
Execute
RedisCallback via underlying RedisOperations. |
Object |
get(Serializable id,
Serializable keyspace) |
<T> T |
get(Serializable id,
Serializable keyspace,
Class<T> type) |
List<?> |
getAllOf(Serializable keyspace) |
List<?> |
getAllOf(Serializable keyspace,
int offset,
int rows) |
RedisConverter |
getConverter()
Get the
RedisConverter in use. |
void |
onApplicationEvent(RedisKeyspaceEvent event) |
Object |
put(Serializable id,
Object item,
Serializable keyspace) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setEnableKeyspaceEvents(RedisKeyValueAdapter.EnableKeyspaceEvents enableKeyspaceEvents)
Configure usage of
KeyExpirationEventMessageListener. |
void |
setKeyspaceNotificationsConfigParameter(String keyspaceNotificationsConfigParameter)
Configure the notify-keyspace-events property if not already set.
|
byte[] |
toBytes(Object source)
Convert given source to binary representation using the underlying
ConversionService. |
void |
update(PartialUpdate<?> update) |
public RedisKeyValueAdapter(RedisOperations<?,?> redisOps)
redisOps - must not be null.public RedisKeyValueAdapter(RedisOperations<?,?> redisOps, RedisMappingContext mappingContext)
RedisKeyValueAdapter with default CustomConversions.redisOps - must not be null.mappingContext - must not be null.public RedisKeyValueAdapter(RedisOperations<?,?> redisOps, RedisMappingContext mappingContext, CustomConversions customConversions)
RedisKeyValueAdapter.redisOps - must not be null.mappingContext - must not be null.customConversions - can be null.public RedisKeyValueAdapter(RedisOperations<?,?> redisOps, RedisConverter redisConverter)
RedisKeyValueAdapter with specific RedisConverter.redisOps - must not be null.redisConverter - must not be null.protected RedisKeyValueAdapter()
public Object put(Serializable id, Object item, Serializable keyspace)
put in interface org.springframework.data.keyvalue.core.KeyValueAdapterpublic boolean contains(Serializable id, Serializable keyspace)
contains in interface org.springframework.data.keyvalue.core.KeyValueAdapterpublic Object get(Serializable id, Serializable keyspace)
get in interface org.springframework.data.keyvalue.core.KeyValueAdapterpublic <T> T get(Serializable id, Serializable keyspace, Class<T> type)
get in interface org.springframework.data.keyvalue.core.KeyValueAdapterget in class org.springframework.data.keyvalue.core.AbstractKeyValueAdapterid - keyspace - type - public Object delete(Serializable id, Serializable keyspace)
delete in interface org.springframework.data.keyvalue.core.KeyValueAdapterpublic <T> T delete(Serializable id, Serializable keyspace, Class<T> type)
delete in interface org.springframework.data.keyvalue.core.KeyValueAdapterdelete in class org.springframework.data.keyvalue.core.AbstractKeyValueAdapterpublic List<?> getAllOf(Serializable keyspace)
getAllOf in interface org.springframework.data.keyvalue.core.KeyValueAdapterpublic List<?> getAllOf(Serializable keyspace, int offset, int rows)
public void deleteAllOf(Serializable keyspace)
deleteAllOf in interface org.springframework.data.keyvalue.core.KeyValueAdapterpublic org.springframework.data.util.CloseableIterator<Map.Entry<Serializable,Object>> entries(Serializable keyspace)
entries in interface org.springframework.data.keyvalue.core.KeyValueAdapterpublic long count(Serializable keyspace)
count in interface org.springframework.data.keyvalue.core.KeyValueAdapterpublic void update(PartialUpdate<?> update)
public <T> T execute(RedisCallback<T> callback)
RedisCallback via underlying RedisOperations.callback - must not be null.RedisOperations.execute(RedisCallback)public RedisConverter getConverter()
RedisConverter in use.public void clear()
clear in interface org.springframework.data.keyvalue.core.KeyValueAdapterpublic byte[] toBytes(Object source)
ConversionService.source - org.springframework.core.convert.ConverterNotFoundExceptionpublic void setEnableKeyspaceEvents(RedisKeyValueAdapter.EnableKeyspaceEvents enableKeyspaceEvents)
KeyExpirationEventMessageListener.enableKeyspaceEvents - public void setKeyspaceNotificationsConfigParameter(String keyspaceNotificationsConfigParameter)
String or
null to retain existing server settings.keyspaceNotificationsConfigParameter - can be null.public void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanInitializingBean.afterPropertiesSet()public void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanExceptionpublic void onApplicationEvent(RedisKeyspaceEvent event)
onApplicationEvent in interface org.springframework.context.ApplicationListener<RedisKeyspaceEvent>public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionCopyright © 2011–2017 Pivotal Software, Inc.. All rights reserved.