Class RedisKeyValueTemplate
java.lang.Object
org.springframework.data.keyvalue.core.KeyValueTemplate
org.springframework.data.redis.core.RedisKeyValueTemplate
- All Implemented Interfaces:
Aware,DisposableBean,ApplicationEventPublisherAware,org.springframework.data.keyvalue.core.KeyValueOperations
public class RedisKeyValueTemplate
extends org.springframework.data.keyvalue.core.KeyValueTemplate
Redis specific implementation of
KeyValueTemplate.- Since:
- 1.7
- Author:
- Christoph Strobl, Mark Paluch
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRedis specificKeyValueCallback. -
Constructor Summary
ConstructorsConstructorDescriptionRedisKeyValueTemplate(RedisKeyValueAdapter adapter, RedisMappingContext mappingContext) Create newRedisKeyValueTemplate. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoPartialUpdate(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> Tupdate(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, 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:
getMappingContextin interfaceorg.springframework.data.keyvalue.core.KeyValueOperations- Overrides:
getMappingContextin classorg.springframework.data.keyvalue.core.KeyValueTemplate
-
find
Retrieve entities by resolving their ids and converting them into required type.
The callback provides either a single id or anIterableof 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:
insertin interfaceorg.springframework.data.keyvalue.core.KeyValueOperations- Overrides:
insertin classorg.springframework.data.keyvalue.core.KeyValueTemplate
-
update
public <T> T update(T objectToUpdate) - Specified by:
updatein interfaceorg.springframework.data.keyvalue.core.KeyValueOperations- Overrides:
updatein classorg.springframework.data.keyvalue.core.KeyValueTemplate
-
update
- Specified by:
updatein interfaceorg.springframework.data.keyvalue.core.KeyValueOperations- Overrides:
updatein classorg.springframework.data.keyvalue.core.KeyValueTemplate
-
doPartialUpdate
-