Class RedisKeyValueTemplate
java.lang.Object
org.springframework.data.keyvalue.core.KeyValueTemplate
org.springframework.data.redis.core.RedisKeyValueTemplate
- All Implemented Interfaces:
Aware
,DisposableBean
,ApplicationEventPublisherAware
,KeyValueOperations
Redis specific implementation of
KeyValueTemplate
.- Since:
- 1.7
- Author:
- Christoph Strobl, Mark Paluch
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionRedisKeyValueTemplate
(RedisKeyValueAdapter adapter, RedisMappingContext mappingContext) Create newRedisKeyValueTemplate
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doPartialUpdate
(PartialUpdate<?> update) <T> List<T>
find
(RedisCallback<?> callback, Class<T> type) Retrieve entities by resolving their ids and converting them into required type.Obtain the underlying redis specificEntityConverter
.<T> T
<T> T
<T> T
update
(T objectToUpdate) Methods inherited from class org.springframework.data.keyvalue.core.KeyValueTemplate
count, count, delete, delete, delete, destroy, execute, executeRequired, exists, find, findAll, findAll, findById, findInRange, findInRange, getKeyValueAdapter, insert, setApplicationEventPublisher, setEventTypesToPublish, setExceptionTranslator
-
Constructor Details
-
RedisKeyValueTemplate
Create newRedisKeyValueTemplate
.- Parameters:
adapter
- must not be null.mappingContext
- must not be null.
-
-
Method Details
-
getConverter
Obtain the underlying redis specificEntityConverter
.- Returns:
- never null.
- Since:
- 2.1
-
getMappingContext
- Specified by:
getMappingContext
in interfaceKeyValueOperations
- Overrides:
getMappingContext
in classKeyValueTemplate
-
find
Retrieve entities by resolving their ids and converting them into required type.
The callback provides either a single id or anIterable
of ids, used for retrieving the actual domain types and shortcuts manual retrieval and conversion of ids viaRedisTemplate
.List<RedisSession> sessions = template.find(new RedisCallback<Set<byte[]>>() { public Set<byte[]< doInRedis(RedisConnection connection) throws DataAccessException { return connection .sMembers("spring:session:sessions:securityContext.authentication.principal.username:user" .getBytes()); } }, RedisSession.class);
- Parameters:
callback
- provides the to retrieve entity ids. Must not be null.type
- must not be null.- Returns:
- empty list if not elements found.
-
insert
- Specified by:
insert
in interfaceKeyValueOperations
- Overrides:
insert
in classKeyValueTemplate
-
update
public <T> T update(T objectToUpdate) - Specified by:
update
in interfaceKeyValueOperations
- Overrides:
update
in classKeyValueTemplate
-
update
- Specified by:
update
in interfaceKeyValueOperations
- Overrides:
update
in classKeyValueTemplate
-
doPartialUpdate
-