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, Mingi Lee
-
Field Summary
Fields inherited from class 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) intersectSize(Collection<? extends RedisSet<?>> sets) Returns the cardinality of the set which would result from the intersection of this set and otherRedisSets.intersectSize(RedisSet<?> set) Returns the cardinality of the set which would result from the intersection of this set and anotherRedisSet.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 AbstractRedisCollection
addAll, checkResult, equals, expire, expireAt, getExpire, getKey, getOperations, hashCode, persist, removeAll, rename, toStringMethods inherited from class AbstractCollection
isEmpty, retainAll, toArray, toArrayMethods inherited from interface BoundKeyOperations
expiration, expire, expire, expireAt, expireAt, getExpire, getKey, persist, renameMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface 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
-
diff
-
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
-
intersect
-
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.
-
intersectSize
Description copied from interface:RedisSetReturns the cardinality of the set which would result from the intersection of this set and anotherRedisSet.- Specified by:
intersectSizein interfaceRedisSet<E>- Parameters:
set- must not be null.- Returns:
- the cardinality of the intersection.
- See Also:
-
intersectSize
Description copied from interface:RedisSetReturns the cardinality of the set which would result from the intersection of this set and otherRedisSets.- Specified by:
intersectSizein interfaceRedisSet<E>- Parameters:
sets- must not be null.- Returns:
- the cardinality of the intersection.
- See Also:
-
union
-
union
-
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
-