Class DefaultRedisSet<E>
java.lang.Object
java.util.AbstractCollection<E>
org.springframework.data.redis.support.collections.AbstractRedisCollection<E>
org.springframework.data.redis.support.collections.DefaultRedisSet<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>,BoundKeyOperations<String>,RedisCollection<E>,RedisSet<E>,RedisStore
Default implementation for
RedisSet. 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
Fields inherited from class org.springframework.data.redis.support.collections.AbstractRedisCollection
ENCODING -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRedisSet(String key, RedisOperations<String, E> operations) Constructs a newDefaultRedisSetinstance.DefaultRedisSet(BoundSetOperations<String, E> boundOps) Constructs a newDefaultRedisSetinstance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclear()booleanbooleancontainsAll(Collection<?> c) diff(Collection<? extends RedisSet<?>> sets) Diff this set and otherRedisSets.Diff this set and anotherRedisSet.diffAndStore(Collection<? extends RedisSet<?>> sets, String destKey) diffAndStore(RedisSet<?> set, String destKey) getType()Returns the associated Redis type.intersect(Collection<? extends RedisSet<?>> sets) Intersect this set and otherRedisSets.Intersect this set and anotherRedisSet.intersectAndStore(Collection<? extends RedisSet<?>> sets, String destKey) intersectAndStore(RedisSet<?> set, String destKey) iterator()Get random element from the set.booleanscan()scan(ScanOptions options) intsize()union(Collection<? extends RedisSet<?>> sets) Union this set and otherRedisSets.Union this set and anotherRedisSet.unionAndStore(Collection<? extends RedisSet<?>> sets, String destKey) unionAndStore(RedisSet<?> set, String destKey) Methods inherited from class org.springframework.data.redis.support.collections.AbstractRedisCollection
addAll, checkResult, equals, expire, expireAt, getExpire, getKey, getOperations, hashCode, persist, removeAll, rename, toStringMethods inherited from class java.util.AbstractCollection
isEmpty, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.data.redis.core.BoundKeyOperations
expiration, expire, expire, expireAt, expireAt, getExpire, getKey, persist, renameMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface org.springframework.data.redis.support.collections.RedisStore
getOperations
-
Constructor Details
-
DefaultRedisSet
Constructs a newDefaultRedisSetinstance.- Parameters:
key- Redis key of this set.operations-RedisOperationsfor the value type of this set.
-
DefaultRedisSet
Constructs a newDefaultRedisSetinstance.- Parameters:
boundOps-BoundSetOperationsfor the value type of this set.
-
-
Method Details
-
diff
Description copied from interface:RedisSetDiff this set and anotherRedisSet. -
diff
Description copied from interface:RedisSetDiff this set and otherRedisSets. -
diffAndStore
Description copied from interface:RedisSetCreate a newRedisSetby diffing this sorted set andRedisSetand store result in destinationdestKey.- Specified by:
diffAndStorein interfaceRedisSet<E>- Parameters:
set- must not be null.destKey- must not be null.- Returns:
- a new
RedisSetpointing atdestKey.
-
diffAndStore
Description copied from interface:RedisSetCreate a newRedisSetby diffing this sorted set and the collectionRedisSetand store result in destinationdestKey.- Specified by:
diffAndStorein interfaceRedisSet<E>- Parameters:
sets- must not be null.destKey- must not be null.- Returns:
- a new
RedisSetpointing atdestKey.
-
intersect
Description copied from interface:RedisSetIntersect this set and anotherRedisSet. -
intersect
Description copied from interface:RedisSetIntersect this set and otherRedisSets. -
intersectAndStore
Description copied from interface:RedisSetCreate a newRedisSetby intersecting this sorted set andRedisSetand store result in destinationdestKey.- Specified by:
intersectAndStorein interfaceRedisSet<E>- Parameters:
set- must not be null.destKey- must not be null.- Returns:
- a new
RedisSetpointing atdestKey
-
intersectAndStore
Description copied from interface:RedisSetCreate a newRedisSetby intersecting this sorted set and the collectionRedisSetand store result in destinationdestKey.- Specified by:
intersectAndStorein interfaceRedisSet<E>- Parameters:
sets- must not be null.destKey- must not be null.- Returns:
- a new
RedisSetpointing atdestKey.
-
union
Description copied from interface:RedisSetUnion this set and anotherRedisSet. -
union
Description copied from interface:RedisSetUnion this set and otherRedisSets. -
unionAndStore
Description copied from interface:RedisSetCreate a newRedisSetby union this sorted set andRedisSetand store result in destinationdestKey.- Specified by:
unionAndStorein interfaceRedisSet<E>- Parameters:
set- must not be null.destKey- must not be null.- Returns:
- a new
RedisSetpointing atdestKey.
-
unionAndStore
Description copied from interface:RedisSetCreate a newRedisSetby union this sorted set and the collectionRedisSetand store result in destinationdestKey.- Specified by:
unionAndStorein interfaceRedisSet<E>- Parameters:
sets- must not be null.destKey- must not be null.- Returns:
- a new
RedisSetpointing atdestKey.
-
randomValue
Description copied from interface:RedisSetGet random element from the set.- Specified by:
randomValuein interfaceRedisSet<E>- Returns:
-
add
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classAbstractCollection<E>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Overrides:
clearin classAbstractCollection<E>
-
contains
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Overrides:
containsin classAbstractCollection<E>
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>- Overrides:
containsAllin classAbstractRedisCollection<E>
-
iterator
-
remove
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classAbstractCollection<E>
-
size
public int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Specified by:
sizein classAbstractCollection<E>
-
getType
Description copied from interface:BoundKeyOperationsReturns the associated Redis type.- Specified by:
getTypein interfaceBoundKeyOperations<E>- Returns:
- key type. null when used in pipeline / transaction.
-
scan
-
scan
- Parameters:
options-- Returns:
- Since:
- 1.4
-