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
ConstructorDescriptionDefaultRedisSet
(String key, RedisOperations<String, E> operations) Constructs a newDefaultRedisSet
instance.DefaultRedisSet
(BoundSetOperations<String, E> boundOps) Constructs a newDefaultRedisSet
instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
clear()
boolean
boolean
containsAll
(Collection<?> c) diff
(Collection<? extends RedisSet<?>> sets) Diff this set and otherRedisSet
s.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 otherRedisSet
s.Intersect this set and anotherRedisSet
.intersectAndStore
(Collection<? extends RedisSet<?>> sets, String destKey) intersectAndStore
(RedisSet<?> set, String destKey) iterator()
Get random element from the set.boolean
scan()
scan
(ScanOptions options) int
size()
union
(Collection<? extends RedisSet<?>> sets) Union this set and otherRedisSet
s.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, toString
Methods inherited from class java.util.AbstractCollection
isEmpty, retainAll, 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, expire, expireAt, expireAt, getExpire, getKey, persist, rename
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface org.springframework.data.redis.support.collections.RedisStore
getOperations
-
Constructor Details
-
DefaultRedisSet
Constructs a newDefaultRedisSet
instance.- Parameters:
key
- Redis key of this set.operations
-RedisOperations
for the value type of this set.
-
DefaultRedisSet
Constructs a newDefaultRedisSet
instance.- Parameters:
boundOps
-BoundSetOperations
for the value type of this set.
-
-
Method Details
-
diff
Description copied from interface:RedisSet
Diff this set and anotherRedisSet
. -
diff
Description copied from interface:RedisSet
Diff this set and otherRedisSet
s. -
diffAndStore
Description copied from interface:RedisSet
Create a newRedisSet
by diffing this sorted set andRedisSet
and store result in destinationdestKey
.- Specified by:
diffAndStore
in interfaceRedisSet<E>
- Parameters:
set
- must not be null.destKey
- must not be null.- Returns:
- a new
RedisSet
pointing atdestKey
.
-
diffAndStore
Description copied from interface:RedisSet
Create a newRedisSet
by diffing this sorted set and the collectionRedisSet
and store result in destinationdestKey
.- Specified by:
diffAndStore
in interfaceRedisSet<E>
- Parameters:
sets
- must not be null.destKey
- must not be null.- Returns:
- a new
RedisSet
pointing atdestKey
.
-
intersect
Description copied from interface:RedisSet
Intersect this set and anotherRedisSet
. -
intersect
Description copied from interface:RedisSet
Intersect this set and otherRedisSet
s. -
intersectAndStore
Description copied from interface:RedisSet
Create a newRedisSet
by intersecting this sorted set andRedisSet
and store result in destinationdestKey
.- Specified by:
intersectAndStore
in interfaceRedisSet<E>
- Parameters:
set
- must not be null.destKey
- must not be null.- Returns:
- a new
RedisSet
pointing atdestKey
-
intersectAndStore
Description copied from interface:RedisSet
Create a newRedisSet
by intersecting this sorted set and the collectionRedisSet
and store result in destinationdestKey
.- Specified by:
intersectAndStore
in interfaceRedisSet<E>
- Parameters:
sets
- must not be null.destKey
- must not be null.- Returns:
- a new
RedisSet
pointing atdestKey
.
-
union
Description copied from interface:RedisSet
Union this set and anotherRedisSet
. -
union
Description copied from interface:RedisSet
Union this set and otherRedisSet
s. -
unionAndStore
Description copied from interface:RedisSet
Create a newRedisSet
by union this sorted set andRedisSet
and store result in destinationdestKey
.- Specified by:
unionAndStore
in interfaceRedisSet<E>
- Parameters:
set
- must not be null.destKey
- must not be null.- Returns:
- a new
RedisSet
pointing atdestKey
.
-
unionAndStore
Description copied from interface:RedisSet
Create a newRedisSet
by union this sorted set and the collectionRedisSet
and store result in destinationdestKey
.- Specified by:
unionAndStore
in interfaceRedisSet<E>
- Parameters:
sets
- must not be null.destKey
- must not be null.- Returns:
- a new
RedisSet
pointing atdestKey
.
-
randomValue
Description copied from interface:RedisSet
Get random element from the set.- Specified by:
randomValue
in interfaceRedisSet<E>
- Returns:
-
add
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classAbstractCollection<E>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- Overrides:
clear
in classAbstractCollection<E>
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Overrides:
contains
in classAbstractCollection<E>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
- Overrides:
containsAll
in classAbstractRedisCollection<E>
-
iterator
-
remove
- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
- Overrides:
remove
in classAbstractCollection<E>
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-
getType
Description copied from interface:BoundKeyOperations
Returns the associated Redis type.- Specified by:
getType
in interfaceBoundKeyOperations<E>
- Returns:
- key type. null when used in pipeline / transaction.
-
scan
-
scan
- Parameters:
options
-- Returns:
- Since:
- 1.4
-