T
- the type of things to storeID
- a "primary key" to the thingspublic abstract class AbstractRedisRepository<T,ID extends java.io.Serializable & java.lang.Comparable<ID>> extends java.lang.Object implements org.springframework.data.repository.PagingAndSortingRepository<T,ID>, RangeCapableRepository<T,ID>
repoPrefix
,
that is used in two ways:
repoPrefix.<id>
Modifier and Type | Field and Description |
---|---|
protected org.springframework.data.redis.core.RedisOperations<java.lang.String,java.lang.String> |
redisOperations |
protected java.lang.String |
repoPrefix |
protected org.springframework.data.redis.core.BoundZSetOperations<java.lang.String,java.lang.String> |
zSetOperations |
Constructor and Description |
---|
AbstractRedisRepository(java.lang.String repoPrefix,
org.springframework.data.redis.core.RedisOperations<java.lang.String,java.lang.String> redisOperations) |
Modifier and Type | Method and Description |
---|---|
long |
count() |
void |
delete(ID id) |
void |
delete(java.lang.Iterable<? extends T> entities) |
void |
delete(T entity) |
void |
deleteAll() |
protected abstract T |
deserialize(ID id,
java.lang.String v)
Deserialize from the String representation to the domain object.
|
protected abstract ID |
deserializeId(java.lang.String string)
Deserialize an entity id from its String representation.
|
boolean |
exists(ID id) |
java.lang.Iterable<T> |
findAll() |
java.lang.Iterable<T> |
findAll(java.lang.Iterable<ID> ids) |
org.springframework.data.domain.Page<T> |
findAll(org.springframework.data.domain.Pageable pageable) |
java.lang.Iterable<T> |
findAll(org.springframework.data.domain.Sort sort) |
java.lang.Iterable<T> |
findAllInRange(ID from,
boolean fromInclusive,
ID to,
boolean toInclusive)
Return entities whose ids range between
from and to . |
T |
findOne(ID id) |
protected java.lang.String |
getPrefix() |
protected ID |
idFromRedisKey(java.lang.String redisKey) |
protected abstract ID |
keyFor(T entity)
Return the entity id for the given domain object.
|
protected java.lang.String |
redisKeyFromId(ID id) |
<S extends T> |
save(java.lang.Iterable<S> entities) |
<S extends T> |
save(S entity) |
protected abstract java.lang.String |
serialize(T entity)
Provide a String representation of the domain entity.
|
protected abstract java.lang.String |
serializeId(ID id)
Return a String representation of the domain ID.
|
void |
setPrefix(java.lang.String string)
Change the prefix after creation.
|
protected void |
trackMembership(java.lang.String redisKey)
Perform bookkeeping of entities managed by this repository.
|
protected java.lang.String repoPrefix
protected org.springframework.data.redis.core.BoundZSetOperations<java.lang.String,java.lang.String> zSetOperations
protected org.springframework.data.redis.core.RedisOperations<java.lang.String,java.lang.String> redisOperations
public AbstractRedisRepository(java.lang.String repoPrefix, org.springframework.data.redis.core.RedisOperations<java.lang.String,java.lang.String> redisOperations)
public long count()
public void delete(ID id)
public void delete(java.lang.Iterable<? extends T> entities)
public void delete(T entity)
public void deleteAll()
public boolean exists(ID id)
public java.lang.Iterable<T> findAll()
public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable)
public java.lang.Iterable<T> findAll(org.springframework.data.domain.Sort sort)
public <S extends T> S save(S entity)
public java.lang.Iterable<T> findAllInRange(ID from, boolean fromInclusive, ID to, boolean toInclusive)
RangeCapableRepository
from
and to
. Note that it is possible that entities with
those exact ids do not exist. If they do exist, the two boolean parameters control whether to include those
results or not. A query from x
to x
returns an empty result, unless both fromInclusive
and toInclusive
are true.findAllInRange
in interface RangeCapableRepository<T,ID extends java.io.Serializable & java.lang.Comparable<ID>>
protected void trackMembership(java.lang.String redisKey)
public <S extends T> java.lang.Iterable<S> save(java.lang.Iterable<S> entities)
protected abstract T deserialize(ID id, java.lang.String v)
id
- the entity idv
- the serialized representation of the domain objectprotected abstract java.lang.String serialize(T entity)
protected abstract java.lang.String serializeId(ID id)
protected abstract ID deserializeId(java.lang.String string)
protected java.lang.String redisKeyFromId(ID id)
protected ID idFromRedisKey(java.lang.String redisKey)
public void setPrefix(java.lang.String string)
protected java.lang.String getPrefix()