Class AbstractRedisCollection<E>
java.lang.Object
java.util.AbstractCollection<E>
org.springframework.data.redis.support.collections.AbstractRedisCollection<E>
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,BoundKeyOperations<String>
,RedisCollection<E>
,RedisStore
- Direct Known Subclasses:
DefaultRedisList
,DefaultRedisSet
,DefaultRedisZSet
public abstract class AbstractRedisCollection<E>
extends AbstractCollection<E>
implements RedisCollection<E>
Base implementation for
RedisCollection
. Provides a skeletal implementation. Note that the collection support
works only with normal, non-pipeline/multi-exec connections as it requires a reply to be sent right away.- Author:
- Costin Leau, Christoph Strobl, Mark Paluch
-
Field Summary
-
Constructor Summary
ConstructorDescriptionAbstractRedisCollection
(String key, RedisOperations<String, E> operations) Constructs a newAbstractRedisCollection
instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addAll
(Collection<? extends E> c) protected void
checkResult
(Object obj) boolean
containsAll
(Collection<?> c) boolean
Sets the key time-to-live/expiration.Sets the key time-to-live/expiration.Returns the expiration of this key.getKey()
Returns the key associated with this entity.Returns the underlying Redis operations used by the backing implementation.int
hashCode()
persist()
Removes the expiration (if any) of the key.boolean
removeAll
(Collection<?> c) void
Renames the key.toString()
Methods inherited from class java.util.AbstractCollection
add, clear, contains, isEmpty, iterator, remove, retainAll, size, toArray, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.data.redis.core.BoundKeyOperations
expire, expireAt, getType
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
ENCODING
- See Also:
-
-
Constructor Details
-
AbstractRedisCollection
Constructs a newAbstractRedisCollection
instance.- Parameters:
key
- Redis key of this collection.operations
-RedisOperations
for the value type of this collection.
-
-
Method Details
-
getKey
Description copied from interface:BoundKeyOperations
Returns the key associated with this entity.- Specified by:
getKey
in interfaceBoundKeyOperations<E>
- Returns:
- key associated with the implementing entity
-
getOperations
Description copied from interface:RedisStore
Returns the underlying Redis operations used by the backing implementation.- Specified by:
getOperations
in interfaceRedisStore
- Returns:
- operations never null.
-
addAll
- Specified by:
addAll
in interfaceCollection<E>
- Overrides:
addAll
in classAbstractCollection<E>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Overrides:
containsAll
in classAbstractCollection<E>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<E>
- Overrides:
removeAll
in classAbstractCollection<E>
-
expire
Description copied from interface:BoundKeyOperations
Sets the key time-to-live/expiration.- Specified by:
expire
in interfaceBoundKeyOperations<E>
- Parameters:
timeout
- expiration valueunit
- expiration unit- Returns:
- true if expiration was set, false otherwise. null when used in pipeline / transaction.
-
expireAt
Description copied from interface:BoundKeyOperations
Sets the key time-to-live/expiration.- Specified by:
expireAt
in interfaceBoundKeyOperations<E>
- Parameters:
date
- expiration date- Returns:
- true if expiration was set, false otherwise. null when used in pipeline / transaction.
-
getExpire
Description copied from interface:BoundKeyOperations
Returns the expiration of this key.- Specified by:
getExpire
in interfaceBoundKeyOperations<E>
- Returns:
- expiration value (in seconds). null when used in pipeline / transaction.
-
persist
Description copied from interface:BoundKeyOperations
Removes the expiration (if any) of the key.- Specified by:
persist
in interfaceBoundKeyOperations<E>
- Returns:
- true if expiration was removed, false otherwise. null when used in pipeline / transaction.
-
rename
Description copied from interface:BoundKeyOperations
Renames the key.
Note: The new name for empty collections will be propagated on add of first element.- Specified by:
rename
in interfaceBoundKeyOperations<E>
- Parameters:
newKey
- new key. Must not be null.
-
equals
- Specified by:
equals
in interfaceCollection<E>
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceCollection<E>
- Overrides:
hashCode
in classObject
-
toString
- Overrides:
toString
in classAbstractCollection<E>
-
checkResult
-