public class RedisKeyValueAdapter extends org.springframework.data.keyvalue.core.AbstractKeyValueAdapter implements InitializingBean, ApplicationContextAware, 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. |
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 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 - 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 InitializingBeanInitializingBean.afterPropertiesSet()public void destroy()
throws Exception
destroy in interface DisposableBeanExceptionpublic void onApplicationEvent(RedisKeyspaceEvent event)
onApplicationEvent in interface ApplicationListener<RedisKeyspaceEvent>public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext in interface ApplicationContextAwareBeansExceptionCopyright © 2011-2015–2017 Pivotal Software, Inc.. All rights reserved.