com.lordofthejars.nosqlunit.redis.embedded
public class SetDatatypeOperations extends ExpirationDatatypeOperations implements RedisDatatypeOperations
ExpirationDatatypeOperations.TtlState| Modifier and Type | Field and Description |
|---|---|
protected static String |
SET |
protected com.google.common.collect.Multimap<ByteBuffer,ByteBuffer> |
setElements |
expirationsInMillis, NO_EXPIRATION| Constructor and Description |
|---|
SetDatatypeOperations() |
| Modifier and Type | Method and Description |
|---|---|
Long |
del(byte[]... keys) |
boolean |
exists(byte[] key) |
void |
flushAllKeys() |
long |
getNumberOfKeys() |
List<byte[]> |
keys() |
boolean |
renameKey(byte[] key,
byte[] newKey) |
Long |
sadd(byte[] key,
byte[]... members)
Add the specified member to the set value stored at key.
|
Long |
scard(byte[] key)
Return the set cardinality (number of elements).
|
Set<byte[]> |
sdiff(byte[]... keys)
Return the difference between the Set stored at key1 and all the Sets
key2, ..., keyN
|
Long |
sdiffstore(byte[] dstkey,
byte[]... keys)
This command works exactly like
SDIFF but
instead of being returned the resulting set is stored in dstkey. |
Set<byte[]> |
sinter(byte[]... keys)
Return the members of a set resulting from the intersection of all the
sets hold at the specified keys.
|
Long |
sinterstore(byte[] dstkey,
byte[]... keys)
This commnad works exactly like
SINTER but
instead of being returned the resulting set is sotred as dstkey. |
Boolean |
sismember(byte[] key,
byte[] member)
Return 1 if member is a member of the set stored at key, otherwise 0 is
returned.
|
Set<byte[]> |
smembers(byte[] key)
Return all the members (elements) of the set value stored at key.
|
Long |
smove(byte[] srckey,
byte[] dstkey,
byte[] member)
Move the specified member from the set at srckey to the set at dstkey.
|
List<byte[]> |
sort(byte[] key) |
byte[] |
spop(byte[] key)
Remove a random element from a Set returning it as return value.
|
byte[] |
srandmember(byte[] key)
Return a random element from a Set, without removing the element.
|
Long |
srem(byte[] key,
byte[]... members)
Remove the specified member from the set value stored at key.
|
Set<byte[]> |
sunion(byte[]... keys)
Return the members of a set resulting from the union of all the sets hold
at the specified keys.
|
Long |
sunionstore(byte[] dstkey,
byte[]... keys)
This command works exactly like
SUNION but
instead of being returned the resulting set is stored as dstkey. |
String |
type() |
addExpirationAt, addExpirationTime, remainingTime, removeExpiration, renameTtlKey, timedoutStateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddExpirationAt, addExpirationTime, remainingTime, removeExpiration, timedoutStateprotected static final String SET
protected com.google.common.collect.Multimap<ByteBuffer,ByteBuffer> setElements
public Long sadd(byte[] key, byte[]... members)
key - members - public Long scard(byte[] key)
key - public Set<byte[]> sdiff(byte[]... keys)
Example:
key1 = [x, a, b, c] key2 = [c] key3 = [a, d] SDIFF key1,key2,key3 => [x, b]Non existing keys are considered like empty sets.
Time complexity:
keys - public Long sdiffstore(byte[] dstkey, byte[]... keys)
SDIFF but
instead of being returned the resulting set is stored in dstkey.dstkey - keys - public Set<byte[]> sinter(byte[]... keys)
LRANGE the result is sent to the client
as a multi-bulk reply (see the protocol specification for more
information). If just a single key is specified, then this command
produces the same result as SMEMBERS. Actually
SMEMBERS is just syntax sugar for SINTER.
Non existing keys are considered like empty sets, so if one of the keys is missing an empty set is returned (since the intersection with an empty set always is an empty set).
keys - public Long sinterstore(byte[] dstkey, byte[]... keys)
SINTER but
instead of being returned the resulting set is sotred as dstkey.
dstkey - keys - public Boolean sismember(byte[] key, byte[] member)
key - member - public Set<byte[]> smembers(byte[] key)
SINTER.
key - public Long smove(byte[] srckey, byte[] dstkey, byte[] member)
If the source set does not exist or does not contain the specified element no operation is performed and zero is returned, otherwise the element is removed from the source set and added to the destination set. On success one is returned, even if the element was already present in the destination set.
An error is raised if the source or destination keys contain a non Set value.
srckey - dstkey - member - public byte[] spop(byte[] key)
The srandmember(byte[]) command does a similar work but the
returned element is not removed from the Set.
key - public byte[] srandmember(byte[] key)
The SPOP command does a similar work but the returned element is popped (removed) from the Set.
key - public Long srem(byte[] key, byte[]... members)
key - member - public Set<byte[]> sunion(byte[]... keys)
LRANGE
the result is sent to the client as a multi-bulk reply (see the protocol
specification for more information). If just a single key is specified,
then this command produces the same result as SMEMBERS.
Non existing keys are considered like empty sets.
keys - public Long sunionstore(byte[] dstkey, byte[]... keys)
SUNION but
instead of being returned the resulting set is stored as dstkey. Any
existing value in dstkey will be over-written.
dstkey - keys - public long getNumberOfKeys()
getNumberOfKeys in interface RedisDatatypeOperationspublic void flushAllKeys()
flushAllKeys in interface RedisDatatypeOperationspublic Long del(byte[]... keys)
del in interface RedisDatatypeOperationspublic boolean exists(byte[] key)
exists in interface RedisDatatypeOperationspublic boolean renameKey(byte[] key,
byte[] newKey)
renameKey in interface RedisDatatypeOperationspublic List<byte[]> keys()
keys in interface RedisDatatypeOperationspublic String type()
type in interface RedisDatatypeOperationspublic List<byte[]> sort(byte[] key)
sort in interface RedisDatatypeOperationsCopyright © 2014. All Rights Reserved.