public class Jedis extends Object implements ServerCommands, DatabaseCommands, JedisCommands, JedisBinaryCommands, ControlCommands, ControlBinaryCommands, ClusterCommands, ModuleCommands, GenericControlCommands, Closeable
Modifier and Type | Field and Description |
---|---|
protected Connection |
connection |
protected static byte[][] |
DUMMY_ARRAY |
Constructor and Description |
---|
Jedis() |
Jedis(Connection connection) |
Jedis(HostAndPort hp) |
Jedis(HostAndPort hostPort,
JedisClientConfig config) |
Jedis(JedisSocketFactory jedisSocketFactory) |
Jedis(JedisSocketFactory jedisSocketFactory,
JedisClientConfig clientConfig) |
Jedis(String url)
This constructor only accepts a URI string.
|
Jedis(String host,
int port) |
Jedis(String host,
int port,
boolean ssl) |
Jedis(String host,
int port,
boolean ssl,
SSLSocketFactory sslSocketFactory,
SSLParameters sslParameters,
HostnameVerifier hostnameVerifier) |
Jedis(String host,
int port,
int timeout) |
Jedis(String host,
int port,
int timeout,
boolean ssl) |
Jedis(String host,
int port,
int timeout,
boolean ssl,
SSLSocketFactory sslSocketFactory,
SSLParameters sslParameters,
HostnameVerifier hostnameVerifier) |
Jedis(String host,
int port,
int connectionTimeout,
int soTimeout) |
Jedis(String host,
int port,
int connectionTimeout,
int soTimeout,
boolean ssl) |
Jedis(String host,
int port,
int connectionTimeout,
int soTimeout,
boolean ssl,
SSLSocketFactory sslSocketFactory,
SSLParameters sslParameters,
HostnameVerifier hostnameVerifier) |
Jedis(String host,
int port,
int connectionTimeout,
int soTimeout,
int infiniteSoTimeout) |
Jedis(String host,
int port,
int connectionTimeout,
int soTimeout,
int infiniteSoTimeout,
boolean ssl,
SSLSocketFactory sslSocketFactory,
SSLParameters sslParameters,
HostnameVerifier hostnameVerifier) |
Jedis(String host,
int port,
JedisClientConfig config) |
Jedis(URI uri) |
Jedis(URI uri,
int timeout) |
Jedis(URI uri,
int connectionTimeout,
int soTimeout) |
Jedis(URI uri,
int connectionTimeout,
int soTimeout,
int infiniteSoTimeout,
SSLSocketFactory sslSocketFactory,
SSLParameters sslParameters,
HostnameVerifier hostnameVerifier) |
Jedis(URI uri,
int connectionTimeout,
int soTimeout,
SSLSocketFactory sslSocketFactory,
SSLParameters sslParameters,
HostnameVerifier hostnameVerifier) |
Jedis(URI uri,
int timeout,
SSLSocketFactory sslSocketFactory,
SSLParameters sslParameters,
HostnameVerifier hostnameVerifier) |
Jedis(URI uri,
JedisClientConfig config) |
Jedis(URI uri,
SSLSocketFactory sslSocketFactory,
SSLParameters sslParameters,
HostnameVerifier hostnameVerifier) |
Modifier and Type | Method and Description |
---|---|
List<String> |
aclCat()
Show the available ACL categories.
|
List<byte[]> |
aclCat(byte[] category)
Show the available ACLs for a given category.
|
List<String> |
aclCat(String category)
Show the available ACLs for a given category.
|
List<byte[]> |
aclCatBinary()
Show the available ACL categories.
|
long |
aclDelUser(byte[] name)
Delete the specified user, from the ACL.
|
long |
aclDelUser(byte[] name,
byte[]... names)
Delete the specified users, from the ACL.
|
long |
aclDelUser(String name)
Delete the specified user, from the ACL.
|
long |
aclDelUser(String name,
String... names)
Delete the specified users, from the ACL.
|
String |
aclGenPass()
Generate a random password
|
String |
aclGenPass(int bits)
Generate a random password
|
byte[] |
aclGenPassBinary()
Generate a random password
|
byte[] |
aclGenPassBinary(int bits)
Generate a random password
|
AccessControlUser |
aclGetUser(byte[] name) |
AccessControlUser |
aclGetUser(String name) |
List<String> |
aclList()
Returns the currently active ACL rules on the Redis Server
|
List<byte[]> |
aclListBinary()
Returns the currently active ACL rules on the Redis Server
|
String |
aclLoad()
This function tells Redis to reload its external ACL rules,
when Redis is configured with an external ACL file
|
List<AccessControlLogEntry> |
aclLog()
Shows the recent ACL security events.
|
List<AccessControlLogEntry> |
aclLog(int limit)
Shows the recent limit ACL security events.
|
List<byte[]> |
aclLogBinary()
Shows the recent ACL security events.
|
List<byte[]> |
aclLogBinary(int limit)
Shows the recent limit ACL security events.
|
String |
aclLogReset()
Reset the script event log
|
String |
aclSave()
Save the currently defined in-memory ACL to disk.
|
String |
aclSetUser(byte[] name)
Create an ACL for the specified user with the default rules.
|
String |
aclSetUser(byte[] name,
byte[]... keys)
Create an ACL for the specified user, while specifying the rules.
|
String |
aclSetUser(String name)
Create an ACL for the specified user with the default rules.
|
String |
aclSetUser(String name,
String... params)
Create an ACL for the specified user, while specifying the rules.
|
List<String> |
aclUsers()
Shows a list of all usernames currently configured with access control
lists (ACL).
|
List<byte[]> |
aclUsersBinary()
Shows a list of all usernames currently configured with access control
lists (ACL).
|
String |
aclWhoAmI()
Returns the username used to authenticate the current connection.
|
byte[] |
aclWhoAmIBinary()
Returns the username used to authenticate the current connection.
|
long |
append(byte[] key,
byte[] value)
If the key already exists and is a string, this command appends the provided value at the end
of the string.
|
long |
append(String key,
String value)
If the key already exists and is a string, this command appends the provided value at the end
of the string.
|
String |
asking() |
String |
auth(String password)
Request for authentication in a password protected Redis server.
|
String |
auth(String user,
String password)
Request for authentication with a Redis Server that is using ACL where user are authenticated with
username and password.
|
String |
bgrewriteaof()
Rewrite the append only file in background when it gets too big.
|
String |
bgsave()
Asynchronously save the DB on disk.
|
long |
bitcount(byte[] key) |
long |
bitcount(byte[] key,
long start,
long end) |
long |
bitcount(String key) |
long |
bitcount(String key,
long start,
long end) |
List<Long> |
bitfield(byte[] key,
byte[]... arguments) |
List<Long> |
bitfield(String key,
String... arguments) |
List<Long> |
bitfieldReadonly(byte[] key,
byte[]... arguments) |
List<Long> |
bitfieldReadonly(String key,
String... arguments) |
long |
bitop(BitOP op,
byte[] destKey,
byte[]... srcKeys) |
long |
bitop(BitOP op,
String destKey,
String... srcKeys) |
long |
bitpos(byte[] key,
boolean value) |
long |
bitpos(byte[] key,
boolean value,
BitPosParams params) |
long |
bitpos(String key,
boolean value) |
long |
bitpos(String key,
boolean value,
BitPosParams params) |
byte[] |
blmove(byte[] srcKey,
byte[] dstKey,
ListDirection from,
ListDirection to,
double timeout)
Pop an element from a list, push it to another list and return it; or block until one is available
|
String |
blmove(String srcKey,
String dstKey,
ListDirection from,
ListDirection to,
double timeout) |
List<byte[]> |
blpop(double timeout,
byte[]... keys) |
KeyedListElement |
blpop(double timeout,
String... keys) |
KeyedListElement |
blpop(double timeout,
String key) |
List<byte[]> |
blpop(int timeout,
byte[]... keys)
BLPOP (and BRPOP) is a blocking list pop primitive.
|
List<String> |
blpop(int timeout,
String... keys)
BLPOP (and BRPOP) is a blocking list pop primitive.
|
List<String> |
blpop(int timeout,
String key) |
List<byte[]> |
brpop(double timeout,
byte[]... keys) |
KeyedListElement |
brpop(double timeout,
String... keys) |
KeyedListElement |
brpop(double timeout,
String key) |
List<byte[]> |
brpop(int timeout,
byte[]... keys)
BLPOP (and BRPOP) is a blocking list pop primitive.
|
List<String> |
brpop(int timeout,
String... keys)
BLPOP (and BRPOP) is a blocking list pop primitive.
|
List<String> |
brpop(int timeout,
String key) |
byte[] |
brpoplpush(byte[] source,
byte[] destination,
int timeout)
Pop a value from a list, push it to another list and return it; or block until one is available
|
String |
brpoplpush(String source,
String destination,
int timeout)
Pop a value from a list, push it to another list and return it; or block until one is available
|
List<byte[]> |
bzpopmax(double timeout,
byte[]... keys) |
KeyedZSetElement |
bzpopmax(double timeout,
String... keys) |
List<byte[]> |
bzpopmin(double timeout,
byte[]... keys) |
KeyedZSetElement |
bzpopmin(double timeout,
String... keys) |
protected void |
checkIsInMultiOrPipeline() |
String |
clientGetname() |
byte[] |
clientGetnameBinary() |
long |
clientId() |
String |
clientInfo() |
byte[] |
clientInfoBinary() |
String |
clientKill(byte[] ipPort) |
long |
clientKill(ClientKillParams params) |
String |
clientKill(String ipPort) |
String |
clientKill(String ip,
int port) |
String |
clientList() |
String |
clientList(ClientType type) |
String |
clientList(long... clientIds) |
byte[] |
clientListBinary() |
byte[] |
clientListBinary(ClientType type) |
byte[] |
clientListBinary(long... clientIds) |
String |
clientPause(long timeout) |
String |
clientPause(long timeout,
ClientPauseMode mode) |
String |
clientSetname(byte[] name) |
String |
clientSetname(String name) |
long |
clientUnblock(long clientId)
Unblock a connection blocked in a blocking command from a different connection.
|
long |
clientUnblock(long clientId,
UnblockType unblockType)
Unblock a connection blocked in a blocking command from a different connection.
|
void |
close() |
String |
clusterAddSlots(int... slots) |
long |
clusterCountKeysInSlot(int slot) |
String |
clusterDelSlots(int... slots) |
String |
clusterFailover() |
String |
clusterFailover(ClusterFailoverOption failoverOption) |
String |
clusterFlushSlots() |
String |
clusterForget(String nodeId) |
List<String> |
clusterGetKeysInSlot(int slot,
int count) |
List<byte[]> |
clusterGetKeysInSlotBinary(int slot,
int count) |
String |
clusterInfo() |
long |
clusterKeySlot(String key) |
String |
clusterMeet(String ip,
int port) |
String |
clusterMyId() |
String |
clusterNodes() |
String |
clusterReplicas(String nodeId) |
String |
clusterReplicate(String nodeId) |
String |
clusterReset() |
String |
clusterReset(ClusterResetType resetType)
resetType can be null for default behavior. |
String |
clusterSaveConfig() |
String |
clusterSetSlotImporting(int slot,
String nodeId) |
String |
clusterSetSlotMigrating(int slot,
String nodeId) |
String |
clusterSetSlotNode(int slot,
String nodeId) |
String |
clusterSetSlotStable(int slot) |
List<String> |
clusterSlaves(String nodeId)
CLUSTER SLAVES command is deprecated since Redis 5. |
List<Object> |
clusterSlots() |
List<byte[]> |
configGet(byte[] pattern)
Retrieve the configuration of a running Redis server.
|
List<String> |
configGet(String pattern)
Retrieve the configuration of a running Redis server.
|
String |
configResetStat()
Reset the stats returned by INFO
|
String |
configRewrite()
The CONFIG REWRITE command rewrites the redis.conf file the server was started with, applying
the minimal changes needed to make it reflect the configuration currently used by the server,
which may be different compared to the original one because of the use of the CONFIG SET
command.
|
String |
configSet(byte[] parameter,
byte[] value)
Alter the configuration of a running Redis server.
|
String |
configSet(String parameter,
String value)
Alter the configuration of a running Redis server.
|
void |
connect() |
boolean |
copy(byte[] srcKey,
byte[] dstKey,
boolean replace)
COPY source destination [DB destination-db] [REPLACE]
|
boolean |
copy(byte[] srcKey,
byte[] dstKey,
int db,
boolean replace)
COPY source destination [DB destination-db] [REPLACE]
|
boolean |
copy(String srcKey,
String dstKey,
boolean replace)
COPY source destination [DB destination-db] [REPLACE]
|
boolean |
copy(String srcKey,
String dstKey,
int db,
boolean replace)
COPY source destination [DB destination-db] [REPLACE]
|
long |
dbSize()
Return the number of keys in the currently selected database.
|
long |
decr(byte[] key)
Decrement the number stored at key by one.
|
long |
decr(String key)
Decrement the number stored at key by one.
|
long |
decrBy(byte[] key,
long decrement)
DECRBY work just like
INCR but instead to decrement by 1 the decrement is
integer. |
long |
decrBy(String key,
long decrement)
IDECRBY work just like
INCR but instead to decrement by 1 the decrement
is integer. |
long |
del(byte[]... keys)
Remove the specified keys.
|
long |
del(byte[] key) |
long |
del(String... keys)
Remove the specified keys.
|
long |
del(String key) |
void |
disconnect() |
byte[] |
dump(byte[] key) |
byte[] |
dump(String key) |
byte[] |
echo(byte[] string) |
String |
echo(String string) |
Object |
eval(byte[] script) |
Object |
eval(byte[] script,
int keyCount,
byte[]... params) |
Object |
eval(byte[] script,
List<byte[]> keys,
List<byte[]> args)
Evaluates scripts using the Lua interpreter built into Redis starting from version 2.6.0.
|
Object |
eval(String script) |
Object |
eval(String script,
int keyCount,
String... params) |
Object |
eval(String script,
List<String> keys,
List<String> args) |
Object |
evalsha(byte[] sha1) |
Object |
evalsha(byte[] sha1,
int keyCount,
byte[]... params) |
Object |
evalsha(byte[] sha1,
List<byte[]> keys,
List<byte[]> args) |
Object |
evalsha(String sha1) |
Object |
evalsha(String sha1,
int keyCount,
String... params) |
Object |
evalsha(String sha1,
List<String> keys,
List<String> args) |
long |
exists(byte[]... keys)
Test if the specified keys exist.
|
boolean |
exists(byte[] key)
Test if the specified key exists.
|
long |
exists(String... keys)
Test if the specified keys exist.
|
boolean |
exists(String key)
Test if the specified key exists.
|
long |
expire(byte[] key,
long seconds)
Set a timeout on the specified key.
|
long |
expire(String key,
long seconds)
Set a timeout on the specified key.
|
long |
expireAt(byte[] key,
long unixTime)
EXPIREAT works exactly like
EXPIRE but instead to get the number of
seconds representing the Time To Live of the key as a second argument (that is a relative way
of specifying the TTL), it takes an absolute one in the form of a UNIX timestamp (Number of
seconds elapsed since 1 Gen 1970). |
long |
expireAt(String key,
long unixTime)
EXPIREAT works exactly like
EXPIRE but instead to get the number
of seconds representing the Time To Live of the key as a second argument (that is a relative
way of specifying the TTL), it takes an absolute one in the form of a UNIX timestamp (Number of
seconds elapsed since 1 Gen 1970). |
String |
failover() |
String |
failover(FailoverParams failoverParams) |
String |
failoverAbort() |
String |
flushAll()
Delete all the keys of all the existing databases, not just the currently selected one.
|
String |
flushAll(FlushMode flushMode)
Delete all the keys of all the existing databases, not just the currently selected one.
|
String |
flushDB()
Delete all the keys of the currently selected DB.
|
String |
flushDB(FlushMode flushMode)
Delete all the keys of the currently selected DB.
|
long |
geoadd(byte[] key,
double longitude,
double latitude,
byte[] member) |
long |
geoadd(byte[] key,
GeoAddParams params,
Map<byte[],GeoCoordinate> memberCoordinateMap) |
long |
geoadd(byte[] key,
Map<byte[],GeoCoordinate> memberCoordinateMap) |
long |
geoadd(String key,
double longitude,
double latitude,
String member) |
long |
geoadd(String key,
GeoAddParams params,
Map<String,GeoCoordinate> memberCoordinateMap) |
long |
geoadd(String key,
Map<String,GeoCoordinate> memberCoordinateMap) |
Double |
geodist(byte[] key,
byte[] member1,
byte[] member2) |
Double |
geodist(byte[] key,
byte[] member1,
byte[] member2,
GeoUnit unit) |
Double |
geodist(String key,
String member1,
String member2) |
Double |
geodist(String key,
String member1,
String member2,
GeoUnit unit) |
List<byte[]> |
geohash(byte[] key,
byte[]... members) |
List<String> |
geohash(String key,
String... members) |
List<GeoCoordinate> |
geopos(byte[] key,
byte[]... members) |
List<GeoCoordinate> |
geopos(String key,
String... members) |
List<GeoRadiusResponse> |
georadius(byte[] key,
double longitude,
double latitude,
double radius,
GeoUnit unit) |
List<GeoRadiusResponse> |
georadius(byte[] key,
double longitude,
double latitude,
double radius,
GeoUnit unit,
GeoRadiusParam param) |
List<GeoRadiusResponse> |
georadius(String key,
double longitude,
double latitude,
double radius,
GeoUnit unit) |
List<GeoRadiusResponse> |
georadius(String key,
double longitude,
double latitude,
double radius,
GeoUnit unit,
GeoRadiusParam param) |
List<GeoRadiusResponse> |
georadiusByMember(byte[] key,
byte[] member,
double radius,
GeoUnit unit) |
List<GeoRadiusResponse> |
georadiusByMember(byte[] key,
byte[] member,
double radius,
GeoUnit unit,
GeoRadiusParam param) |
List<GeoRadiusResponse> |
georadiusByMember(String key,
String member,
double radius,
GeoUnit unit) |
List<GeoRadiusResponse> |
georadiusByMember(String key,
String member,
double radius,
GeoUnit unit,
GeoRadiusParam param) |
List<GeoRadiusResponse> |
georadiusByMemberReadonly(byte[] key,
byte[] member,
double radius,
GeoUnit unit) |
List<GeoRadiusResponse> |
georadiusByMemberReadonly(byte[] key,
byte[] member,
double radius,
GeoUnit unit,
GeoRadiusParam param) |
List<GeoRadiusResponse> |
georadiusByMemberReadonly(String key,
String member,
double radius,
GeoUnit unit) |
List<GeoRadiusResponse> |
georadiusByMemberReadonly(String key,
String member,
double radius,
GeoUnit unit,
GeoRadiusParam param) |
long |
georadiusByMemberStore(byte[] key,
byte[] member,
double radius,
GeoUnit unit,
GeoRadiusParam param,
GeoRadiusStoreParam storeParam) |
long |
georadiusByMemberStore(String key,
String member,
double radius,
GeoUnit unit,
GeoRadiusParam param,
GeoRadiusStoreParam storeParam) |
List<GeoRadiusResponse> |
georadiusReadonly(byte[] key,
double longitude,
double latitude,
double radius,
GeoUnit unit) |
List<GeoRadiusResponse> |
georadiusReadonly(byte[] key,
double longitude,
double latitude,
double radius,
GeoUnit unit,
GeoRadiusParam param) |
List<GeoRadiusResponse> |
georadiusReadonly(String key,
double longitude,
double latitude,
double radius,
GeoUnit unit) |
List<GeoRadiusResponse> |
georadiusReadonly(String key,
double longitude,
double latitude,
double radius,
GeoUnit unit,
GeoRadiusParam param) |
long |
georadiusStore(byte[] key,
double longitude,
double latitude,
double radius,
GeoUnit unit,
GeoRadiusParam param,
GeoRadiusStoreParam storeParam) |
long |
georadiusStore(String key,
double longitude,
double latitude,
double radius,
GeoUnit unit,
GeoRadiusParam param,
GeoRadiusStoreParam storeParam) |
byte[] |
get(byte[] key)
Get the value of the specified key.
|
String |
get(String key)
Get the value of the specified key.
|
boolean |
getbit(byte[] key,
long offset)
Returns the bit value at offset in the string value stored at key
|
boolean |
getbit(String key,
long offset)
Returns the bit value at offset in the string value stored at key
|
Connection |
getClient() |
Connection |
getConnection() |
int |
getDB() |
byte[] |
getDel(byte[] key)
Get the value of key and delete the key.
|
String |
getDel(String key)
Get the value of key and delete the key.
|
byte[] |
getEx(byte[] key,
GetExParams params) |
String |
getEx(String key,
GetExParams params) |
protected static byte[][] |
getParamsWithBinary(List<byte[]> keys,
List<byte[]> args) |
byte[] |
getrange(byte[] key,
long startOffset,
long endOffset) |
String |
getrange(String key,
long startOffset,
long endOffset) |
byte[] |
getSet(byte[] key,
byte[] value)
GETSET is an atomic set this value and return the old value command.
|
String |
getSet(String key,
String value)
GETSET is an atomic set this value and return the old value command.
|
long |
hdel(byte[] key,
byte[]... fields)
Remove the specified field from an hash stored at key.
|
long |
hdel(String key,
String... fields)
Remove the specified field from an hash stored at key.
|
boolean |
hexists(byte[] key,
byte[] field)
Test for existence of a specified field in a hash.
|
boolean |
hexists(String key,
String field)
Test for existence of a specified field in a hash.
|
byte[] |
hget(byte[] key,
byte[] field)
If key holds a hash, retrieve the value associated to the specified field.
|
String |
hget(String key,
String field)
If key holds a hash, retrieve the value associated to the specified field.
|
Map<byte[],byte[]> |
hgetAll(byte[] key)
Return all the fields and associated values in a hash.
|
Map<String,String> |
hgetAll(String key)
Return all the fields and associated values in a hash.
|
long |
hincrBy(byte[] key,
byte[] field,
long value)
Increment the number stored at field in the hash at key by value.
|
long |
hincrBy(String key,
String field,
long value)
Increment the number stored at field in the hash at key by value.
|
double |
hincrByFloat(byte[] key,
byte[] field,
double value)
Increment the number stored at field in the hash at key by a double precision floating point
value.
|
double |
hincrByFloat(String key,
String field,
double value)
Increment the number stored at field in the hash at key by a double precision floating point
value.
|
Set<byte[]> |
hkeys(byte[] key)
Return all the fields in a hash.
|
Set<String> |
hkeys(String key)
Return all the fields in a hash.
|
long |
hlen(byte[] key)
Return the number of items in a hash.
|
long |
hlen(String key)
Return the number of items in a hash.
|
List<byte[]> |
hmget(byte[] key,
byte[]... fields)
Retrieve the values associated to the specified fields.
|
List<String> |
hmget(String key,
String... fields)
Retrieve the values associated to the specified fields.
|
String |
hmset(byte[] key,
Map<byte[],byte[]> hash)
Set the respective fields to the respective values.
|
String |
hmset(String key,
Map<String,String> hash)
Set the respective fields to the respective values.
|
byte[] |
hrandfield(byte[] key)
Get one random field from a hash.
|
List<byte[]> |
hrandfield(byte[] key,
long count)
Get multiple random fields from a hash.
|
String |
hrandfield(String key)
Get one random field from a hash.
|
List<String> |
hrandfield(String key,
long count)
Get multiple random fields from a hash.
|
Map<byte[],byte[]> |
hrandfieldWithValues(byte[] key,
long count)
Get one or multiple random fields with values from a hash.
|
Map<String,String> |
hrandfieldWithValues(String key,
long count)
Get one or multiple random fields with values from a hash.
|
ScanResult<Map.Entry<byte[],byte[]>> |
hscan(byte[] key,
byte[] cursor) |
ScanResult<Map.Entry<byte[],byte[]>> |
hscan(byte[] key,
byte[] cursor,
ScanParams params) |
ScanResult<Map.Entry<String,String>> |
hscan(String key,
String cursor,
ScanParams params) |
long |
hset(byte[] key,
byte[] field,
byte[] value)
Set the specified hash field to the specified value.
|
long |
hset(byte[] key,
Map<byte[],byte[]> hash) |
long |
hset(String key,
Map<String,String> hash) |
long |
hset(String key,
String field,
String value)
Set the specified hash field to the specified value.
|
long |
hsetnx(byte[] key,
byte[] field,
byte[] value)
Set the specified hash field to the specified value if the field not exists.
|
long |
hsetnx(String key,
String field,
String value)
Set the specified hash field to the specified value if the field not exists.
|
long |
hstrlen(byte[] key,
byte[] field) |
long |
hstrlen(String key,
String field) |
List<byte[]> |
hvals(byte[] key)
Return all the values in a hash.
|
List<String> |
hvals(String key)
Return all the values in a hash.
|
long |
incr(byte[] key)
Increment the number stored at key by one.
|
long |
incr(String key)
Increment the number stored at key by one.
|
long |
incrBy(byte[] key,
long increment)
INCRBY work just like
INCR but instead to increment by 1 the increment is
integer. |
long |
incrBy(String key,
long increment)
INCRBY work just like
INCR but instead to increment by 1 the increment is
integer. |
double |
incrByFloat(byte[] key,
double increment)
INCRBYFLOAT work just like
incrBy(byte[], long) INCRBY} but increments by floats
instead of integers. |
double |
incrByFloat(String key,
double increment)
INCRBYFLOAT
|
String |
info()
Provide information and statistics about the server.
|
String |
info(String section)
The INFO command returns information and statistics about the server in a format that is simple
to parse by computers and easy to read by humans.
|
boolean |
isBroken() |
boolean |
isConnected() |
Set<byte[]> |
keys(byte[] pattern)
Returns all the keys matching the glob-style pattern as space separated strings.
|
Set<String> |
keys(String pattern) |
long |
lastsave()
Return the UNIX time stamp of the last successfully saving of the dataset on disk.
|
byte[] |
lindex(byte[] key,
long index)
Return the specified element of the list stored at the specified key.
|
String |
lindex(String key,
long index)
Return the specified element of the list stored at the specified key.
|
long |
linsert(byte[] key,
ListPosition where,
byte[] pivot,
byte[] value) |
long |
linsert(String key,
ListPosition where,
String pivot,
String value) |
long |
llen(byte[] key)
Return the length of the list stored at the specified key.
|
long |
llen(String key)
Return the length of the list stored at the specified key.
|
byte[] |
lmove(byte[] srcKey,
byte[] dstKey,
ListDirection from,
ListDirection to)
Pop an element from a list, push it to another list and return it
|
String |
lmove(String srcKey,
String dstKey,
ListDirection from,
ListDirection to) |
byte[] |
lpop(byte[] key)
Atomically return and remove the first (LPOP) or last (RPOP) element of the list.
|
List<byte[]> |
lpop(byte[] key,
int count) |
String |
lpop(String key)
Atomically return and remove the first (LPOP) or last (RPOP) element of the list.
|
List<String> |
lpop(String key,
int count) |
Long |
lpos(byte[] key,
byte[] element)
Returns the index of the first matching element inside a redis list.
|
Long |
lpos(byte[] key,
byte[] element,
LPosParams params)
In case there are multiple matches Rank option specifies the "rank" of the element to return.
|
List<Long> |
lpos(byte[] key,
byte[] element,
LPosParams params,
long count)
Count will return list of position of all the first N matching elements.
|
Long |
lpos(String key,
String element) |
Long |
lpos(String key,
String element,
LPosParams params) |
List<Long> |
lpos(String key,
String element,
LPosParams params,
long count) |
long |
lpush(byte[] key,
byte[]... strings)
Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key.
|
long |
lpush(String key,
String... strings)
Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key.
|
long |
lpushx(byte[] key,
byte[]... string) |
long |
lpushx(String key,
String... string) |
List<byte[]> |
lrange(byte[] key,
long start,
long stop)
Return the specified elements of the list stored at the specified key.
|
List<String> |
lrange(String key,
long start,
long stop)
Return the specified elements of the list stored at the specified key.
|
long |
lrem(byte[] key,
long count,
byte[] value)
Remove the first count occurrences of the value element from the list.
|
long |
lrem(String key,
long count,
String value)
Remove the first count occurrences of the value element from the list.
|
String |
lset(byte[] key,
long index,
byte[] value)
Set a new value as the element at index position of the List at key.
|
String |
lset(String key,
long index,
String value)
Set a new value as the element at index position of the List at key.
|
String |
ltrim(byte[] key,
long start,
long stop)
Trim an existing list so that it will contain only the specified range of elements specified.
|
String |
ltrim(String key,
long start,
long stop)
Trim an existing list so that it will contain only the specified range of elements specified.
|
String |
memoryDoctor() |
byte[] |
memoryDoctorBinary() |
Long |
memoryUsage(byte[] key) |
Long |
memoryUsage(byte[] key,
int samples) |
Long |
memoryUsage(String key) |
Long |
memoryUsage(String key,
int samples) |
List<byte[]> |
mget(byte[]... keys)
Get the values of all the specified keys.
|
List<String> |
mget(String... keys)
Get the values of all the specified keys.
|
String |
migrate(String host,
int port,
byte[] key,
int timeout) |
String |
migrate(String host,
int port,
byte[] key,
int destinationDb,
int timeout) |
String |
migrate(String host,
int port,
int destinationDB,
int timeout,
MigrateParams params,
byte[]... keys) |
String |
migrate(String host,
int port,
int destinationDB,
int timeout,
MigrateParams params,
String... keys) |
String |
migrate(String host,
int port,
int timeout,
MigrateParams params,
byte[]... keys) |
String |
migrate(String host,
int port,
int timeout,
MigrateParams params,
String... keys) |
String |
migrate(String host,
int port,
String key,
int timeout) |
String |
migrate(String host,
int port,
String key,
int destinationDb,
int timeout) |
List<Module> |
moduleList() |
String |
moduleLoad(String path) |
String |
moduleUnload(String name) |
void |
monitor(JedisMonitor jedisMonitor)
Dump all the received requests in real time.
|
long |
move(byte[] key,
int dbIndex)
Move the specified key from the currently selected DB to the specified destination DB.
|
long |
move(String key,
int dbIndex)
Move the specified key from the currently selected DB to the specified destination DB.
|
String |
mset(byte[]... keysvalues)
Set the the respective keys to the respective values.
|
String |
mset(String... keysvalues)
Set the the respective keys to the respective values.
|
long |
msetnx(byte[]... keysvalues)
Set the the respective keys to the respective values.
|
long |
msetnx(String... keysvalues)
Set the the respective keys to the respective values.
|
Transaction |
multi() |
byte[] |
objectEncoding(byte[] key) |
String |
objectEncoding(String key) |
Long |
objectFreq(byte[] key) |
Long |
objectFreq(String key) |
List<String> |
objectHelp() |
List<byte[]> |
objectHelpBinary() |
Long |
objectIdletime(byte[] key) |
Long |
objectIdletime(String key) |
Long |
objectRefcount(byte[] key) |
Long |
objectRefcount(String key) |
long |
persist(byte[] key)
Undo a
expire at turning the expire key into a normal key. |
long |
persist(String key)
Undo a
expire at turning the expire key into a normal key. |
long |
pexpire(byte[] key,
long milliseconds)
Set a timeout on the specified key.
|
long |
pexpire(String key,
long milliseconds) |
long |
pexpireAt(byte[] key,
long millisecondsTimestamp) |
long |
pexpireAt(String key,
long millisecondsTimestamp) |
long |
pfadd(byte[] key,
byte[]... elements) |
long |
pfadd(String key,
String... elements) |
long |
pfcount(byte[]... keys) |
long |
pfcount(byte[] key) |
long |
pfcount(String... keys) |
long |
pfcount(String key) |
String |
pfmerge(byte[] destkey,
byte[]... sourcekeys) |
String |
pfmerge(String destkey,
String... sourcekeys) |
String |
ping()
This command is often used to test if a connection is still alive, or to measure latency.
|
byte[] |
ping(byte[] message)
Works same as
ping() but returns argument message instead of PONG . |
String |
ping(String message)
Works same as ping() but returns argument message instead of PONG.
|
Pipeline |
pipelined() |
String |
psetex(byte[] key,
long milliseconds,
byte[] value)
PSETEX works exactly like
#setex(byte[], int, byte[]) with the sole difference that the
expire time is specified in milliseconds instead of seconds. |
String |
psetex(String key,
long milliseconds,
String value)
PSETEX works exactly like
#setex(String, int, String) with the sole difference that the
expire time is specified in milliseconds instead of seconds. |
void |
psubscribe(BinaryJedisPubSub jedisPubSub,
byte[]... patterns) |
void |
psubscribe(JedisPubSub jedisPubSub,
String... patterns) |
long |
pttl(byte[] key) |
long |
pttl(String key) |
long |
publish(byte[] channel,
byte[] message) |
long |
publish(String channel,
String message) |
List<String> |
pubsubChannels() |
List<String> |
pubsubChannels(String pattern) |
Long |
pubsubNumPat() |
Map<String,Long> |
pubsubNumSub(String... channels) |
String |
quit()
Ask the server to silently close the connection.
|
byte[] |
randomBinaryKey()
Return a randomly selected key from the currently selected DB.
|
String |
randomKey()
Return a randomly selected key from the currently selected DB.
|
String |
readonly() |
String |
readwrite() |
String |
rename(byte[] oldkey,
byte[] newkey)
Atomically renames the key oldkey to newkey.
|
String |
rename(String oldkey,
String newkey)
Atomically renames the key oldkey to newkey.
|
long |
renamenx(byte[] oldkey,
byte[] newkey)
Rename oldkey into newkey but fails if the destination key newkey already exists.
|
long |
renamenx(String oldkey,
String newkey)
Rename oldkey into newkey but fails if the destination key newkey already exists.
|
void |
resetState() |
String |
restore(byte[] key,
long ttl,
byte[] serializedValue) |
String |
restore(byte[] key,
long ttl,
byte[] serializedValue,
RestoreParams params) |
String |
restore(String key,
long ttl,
byte[] serializedValue) |
String |
restore(String key,
long ttl,
byte[] serializedValue,
RestoreParams params) |
List<Object> |
role() |
List<Object> |
roleBinary() |
byte[] |
rpop(byte[] key)
Atomically return and remove the first (LPOP) or last (RPOP) element of the list.
|
List<byte[]> |
rpop(byte[] key,
int count) |
String |
rpop(String key)
Atomically return and remove the first (LPOP) or last (RPOP) element of the list.
|
List<String> |
rpop(String key,
int count) |
byte[] |
rpoplpush(byte[] srckey,
byte[] dstkey)
Atomically return and remove the last (tail) element of the srckey list, and push the element
as the first (head) element of the dstkey list.
|
String |
rpoplpush(String srckey,
String dstkey)
Atomically return and remove the last (tail) element of the srckey list, and push the element
as the first (head) element of the dstkey list.
|
long |
rpush(byte[] key,
byte[]... strings)
Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key.
|
long |
rpush(String key,
String... strings)
Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key.
|
long |
rpushx(byte[] key,
byte[]... string) |
long |
rpushx(String key,
String... string) |
long |
sadd(byte[] key,
byte[]... members)
Add the specified member to the set value stored at key.
|
long |
sadd(String key,
String... members)
Add the specified member to the set value stored at key.
|
String |
save()
Synchronously save the DB on disk.
|
ScanResult<byte[]> |
scan(byte[] cursor) |
ScanResult<byte[]> |
scan(byte[] cursor,
ScanParams params) |
ScanResult<byte[]> |
scan(byte[] cursor,
ScanParams params,
byte[] type) |
ScanResult<String> |
scan(String cursor) |
ScanResult<String> |
scan(String cursor,
ScanParams params) |
ScanResult<String> |
scan(String cursor,
ScanParams params,
String type) |
long |
scard(byte[] key)
Return the set cardinality (number of elements).
|
long |
scard(String key)
Return the set cardinality (number of elements).
|
List<Boolean> |
scriptExists(byte[]... sha1) |
Boolean |
scriptExists(byte[] sha1) |
List<Boolean> |
scriptExists(String... sha1) |
Boolean |
scriptExists(String sha1) |
String |
scriptFlush() |
String |
scriptFlush(FlushMode flushMode) |
String |
scriptKill() |
byte[] |
scriptLoad(byte[] script) |
String |
scriptLoad(String script) |
Set<byte[]> |
sdiff(byte[]... keys)
Return the difference between the Set stored at key1 and all the Sets key2, ..., keyN
|
Set<String> |
sdiff(String... 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. |
long |
sdiffstore(String dstkey,
String... keys)
This command works exactly like
SDIFF but instead of being returned
the resulting set is stored in dstkey. |
String |
select(int index)
Select the DB with having the specified zero-based numeric index.
|
Object |
sendBlockingCommand(ProtocolCommand cmd,
byte[]... args) |
Object |
sendBlockingCommand(ProtocolCommand cmd,
String... args) |
Object |
sendCommand(ProtocolCommand cmd) |
Object |
sendCommand(ProtocolCommand cmd,
byte[]... args) |
Object |
sendCommand(ProtocolCommand cmd,
String... args) |
String |
set(byte[] key,
byte[] value)
Set the string value as value of the key.
|
String |
set(byte[] key,
byte[] value,
SetParams params)
Set the string value as value of the key.
|
String |
set(String key,
String value)
Set the string value as value of the key.
|
String |
set(String key,
String value,
SetParams params)
Set the string value as value of the key.
|
boolean |
setbit(byte[] key,
long offset,
boolean value)
Sets or clears the bit at offset in the string value stored at key
|
boolean |
setbit(String key,
long offset,
boolean value)
Sets or clears the bit at offset in the string value stored at key
|
protected void |
setDataSource(Pool<Jedis> jedisPool) |
String |
setex(byte[] key,
long seconds,
byte[] value)
The command is exactly equivalent to the following group of commands:
SET + EXPIRE . |
String |
setex(String key,
long seconds,
String value)
The command is exactly equivalent to the following group of commands:
SET + EXPIRE . |
long |
setnx(byte[] key,
byte[] value)
SETNX works exactly like
SET with the only difference that if the
key already exists no operation is performed. |
long |
setnx(String key,
String value)
SETNX works exactly like
SET with the only difference that if the
key already exists no operation is performed. |
long |
setrange(byte[] key,
long offset,
byte[] value) |
long |
setrange(String key,
long offset,
String value) |
void |
shutdown()
Synchronously save the DB on disk, then shutdown the server.
|
void |
shutdown(SaveMode saveMode) |
Set<byte[]> |
sinter(byte[]... keys)
Return the members of a set resulting from the intersection of all the sets hold at the
specified keys.
|
Set<String> |
sinter(String... 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 commanad works exactly like
SINTER but instead of being returned
the resulting set is stored as dstkey. |
long |
sinterstore(String dstkey,
String... keys)
This command works exactly like
SINTER but instead of being returned
the resulting set is stored as dstkey. |
boolean |
sismember(byte[] key,
byte[] member)
Return true if member is a member of the set stored at key, otherwise false is returned.
|
boolean |
sismember(String key,
String member)
Return true if member is a member of the set stored at key, otherwise false is returned.
|
String |
slaveof(String host,
int port)
Change the replication settings.
|
String |
slaveofNoOne()
SLAVEOF NO ONE will stop replication, turning the server into a MASTER, but will not discard
the replication.
|
List<Slowlog> |
slowlogGet() |
List<Slowlog> |
slowlogGet(long entries) |
List<Object> |
slowlogGetBinary() |
List<Object> |
slowlogGetBinary(long entries) |
long |
slowlogLen() |
String |
slowlogReset() |
Set<byte[]> |
smembers(byte[] key)
Return all the members (elements) of the set value stored at key.
|
Set<String> |
smembers(String key)
Return all the members (elements) of the set value stored at key.
|
List<Boolean> |
smismember(byte[] key,
byte[]... members)
Returns whether each member is a member of the set stored at key.
|
List<Boolean> |
smismember(String key,
String... members)
Returns whether each member is a member of the set 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.
|
long |
smove(String srckey,
String dstkey,
String member)
Move the specified member from the set at srckey to the set at dstkey.
|
List<byte[]> |
sort(byte[] key)
Sort a Set or a List.
|
long |
sort(byte[] key,
byte[] dstkey)
Sort a Set or a List and Store the Result at dstkey.
|
List<byte[]> |
sort(byte[] key,
SortingParams sortingParameters)
Sort a Set or a List accordingly to the specified parameters.
|
long |
sort(byte[] key,
SortingParams sortingParameters,
byte[] dstkey)
Sort a Set or a List accordingly to the specified parameters and store the result at dstkey.
|
List<String> |
sort(String key)
Sort a Set or a List.
|
List<String> |
sort(String key,
SortingParams sortingParameters)
Sort a Set or a List accordingly to the specified parameters.
|
long |
sort(String key,
SortingParams sortingParameters,
String dstkey)
Sort a Set or a List accordingly to the specified parameters and store the result at dstkey.
|
long |
sort(String key,
String dstkey)
Sort a Set or a List and Store the Result at dstkey.
|
byte[] |
spop(byte[] key)
Remove a random element from a Set returning it as return value.
|
Set<byte[]> |
spop(byte[] key,
long count) |
String |
spop(String key)
Remove a random element from a Set returning it as return value.
|
Set<String> |
spop(String key,
long count) |
byte[] |
srandmember(byte[] key)
Return a random element from a Set, without removing the element.
|
List<byte[]> |
srandmember(byte[] key,
int count) |
String |
srandmember(String key)
Return a random element from a Set, without removing the element.
|
List<String> |
srandmember(String key,
int count)
Return a random elements from a Set, without removing the elements.
|
long |
srem(byte[] key,
byte[]... member)
Remove the specified member from the set value stored at key.
|
long |
srem(String key,
String... members)
Remove the specified member from the set value stored at key.
|
ScanResult<byte[]> |
sscan(byte[] key,
byte[] cursor) |
ScanResult<byte[]> |
sscan(byte[] key,
byte[] cursor,
ScanParams params) |
ScanResult<String> |
sscan(String key,
String cursor,
ScanParams params) |
LCSMatchResult |
strAlgoLCSKeys(byte[] keyA,
byte[] keyB,
StrAlgoLCSParams params) |
LCSMatchResult |
strAlgoLCSKeys(String keyA,
String keyB,
StrAlgoLCSParams params)
Calculate the longest common subsequence of keyA and keyB.
|
LCSMatchResult |
strAlgoLCSStrings(byte[] strA,
byte[] strB,
StrAlgoLCSParams params) |
LCSMatchResult |
strAlgoLCSStrings(String strA,
String strB,
StrAlgoLCSParams params)
Calculate the longest common subsequence of strA and strB.
|
long |
strlen(byte[] key) |
long |
strlen(String key) |
void |
subscribe(BinaryJedisPubSub jedisPubSub,
byte[]... channels) |
void |
subscribe(JedisPubSub jedisPubSub,
String... channels) |
byte[] |
substr(byte[] key,
int start,
int end)
Return a subset of the string from offset start to offset end (both offsets are inclusive).
|
String |
substr(String key,
int start,
int end)
Return a subset of the string from offset start to offset end (both offsets are inclusive).
|
Set<byte[]> |
sunion(byte[]... keys)
Return the members of a set resulting from the union of all the sets hold at the specified
keys.
|
Set<String> |
sunion(String... 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. |
long |
sunionstore(String dstkey,
String... keys)
This command works exactly like
SUNION but instead of being returned
the resulting set is stored as dstkey. |
String |
swapDB(int index1,
int index2)
This command swaps two Redis databases, so that immediately all the clients connected to a
given database will see the data of the other database, and the other way around.
|
List<String> |
time() |
String |
toString() |
long |
touch(byte[]... keys)
Alters the last access time of a key(s).
|
long |
touch(byte[] key) |
long |
touch(String... keys)
Alters the last access time of a key(s).
|
long |
touch(String key) |
long |
ttl(byte[] key)
The TTL command returns the remaining time to live in seconds of a key that has an
EXPIRE set. |
long |
ttl(String key)
The TTL command returns the remaining time to live in seconds of a key that has an
EXPIRE set. |
String |
type(byte[] key)
Return the type of the value stored at key in form of a string.
|
String |
type(String key)
Return the type of the value stored at key in form of a string.
|
long |
unlink(byte[]... keys)
This command is very similar to DEL: it removes the specified keys.
|
long |
unlink(byte[] key) |
long |
unlink(String... keys)
This command is very similar to DEL: it removes the specified keys.
|
long |
unlink(String key) |
String |
unwatch() |
long |
waitReplicas(int replicas,
long timeout)
Syncrhonous replication of Redis as described here: http://antirez.com/news/66.
|
String |
watch(byte[]... keys) |
String |
watch(String... keys) |
long |
xack(byte[] key,
byte[] group,
byte[]... ids) |
long |
xack(String key,
String group,
StreamEntryID... ids)
XACK key group ID [ID ...]
|
StreamEntryID |
xadd_v2(String key,
XAddParams params,
Map<String,String> hash) |
byte[] |
xadd(byte[] key,
XAddParams params,
Map<byte[],byte[]> hash) |
StreamEntryID |
xadd(String key,
StreamEntryID id,
Map<String,String> hash)
XADD key ID field string [field string ...]
|
List<Object> |
xautoclaim(byte[] key,
byte[] groupName,
byte[] consumerName,
long minIdleTime,
byte[] start,
XAutoClaimParams params) |
Map.Entry<StreamEntryID,List<StreamEntry>> |
xautoclaim(String key,
String group,
String consumerName,
long minIdleTime,
StreamEntryID start,
XAutoClaimParams params)
XAUTOCLAIM key group consumer min-idle-time start [COUNT count]
|
List<Object> |
xautoclaimJustId(byte[] key,
byte[] groupName,
byte[] consumerName,
long minIdleTime,
byte[] start,
XAutoClaimParams params) |
Map.Entry<StreamEntryID,List<StreamEntryID>> |
xautoclaimJustId(String key,
String group,
String consumerName,
long minIdleTime,
StreamEntryID start,
XAutoClaimParams params)
XAUTOCLAIM key group consumer min-idle-time start [COUNT count] JUSTID
|
List<byte[]> |
xclaim(byte[] key,
byte[] group,
byte[] consumername,
long minIdleTime,
XClaimParams params,
byte[]... ids) |
List<StreamEntry> |
xclaim(String key,
String group,
String consumername,
long minIdleTime,
XClaimParams params,
StreamEntryID... ids)
XCLAIM
|
List<byte[]> |
xclaimJustId(byte[] key,
byte[] group,
byte[] consumername,
long minIdleTime,
XClaimParams params,
byte[]... ids) |
List<StreamEntryID> |
xclaimJustId(String key,
String group,
String consumername,
long minIdleTime,
XClaimParams params,
StreamEntryID... ids)
XCLAIM
|
long |
xdel(byte[] key,
byte[]... ids) |
long |
xdel(String key,
StreamEntryID... ids)
XDEL key ID [ID ...]
|
String |
xgroupCreate(byte[] key,
byte[] consumer,
byte[] id,
boolean makeStream) |
String |
xgroupCreate(String key,
String groupname,
StreamEntryID id,
boolean makeStream)
XGROUP CREATE
|
long |
xgroupDelConsumer(byte[] key,
byte[] consumer,
byte[] consumerName) |
long |
xgroupDelConsumer(String key,
String groupname,
String consumerName)
XGROUP DELCONSUMER
|
long |
xgroupDestroy(byte[] key,
byte[] consumer) |
long |
xgroupDestroy(String key,
String groupname)
XGROUP DESTROY
|
String |
xgroupSetID(byte[] key,
byte[] consumer,
byte[] id) |
String |
xgroupSetID(String key,
String groupname,
StreamEntryID id)
XGROUP SETID
|
List<Object> |
xinfoConsumers(byte[] key,
byte[] group) |
List<StreamConsumersInfo> |
xinfoConsumers(String key,
String group)
Introspection command used in order to retrieve different information about consumers in the group
|
List<Object> |
xinfoGroup(byte[] key) |
List<StreamGroupInfo> |
xinfoGroup(String key)
Introspection command used in order to retrieve different information about groups in the stream
|
Object |
xinfoStream(byte[] key) |
StreamInfo |
xinfoStream(String key)
Introspection command used in order to retrieve different information about the stream
|
long |
xlen(byte[] key) |
long |
xlen(String key)
XLEN key
|
Object |
xpending(byte[] key,
byte[] groupname) |
List<Object> |
xpending(byte[] key,
byte[] groupname,
byte[] start,
byte[] end,
int count,
byte[] consumername) |
List<Object> |
xpending(byte[] key,
byte[] groupname,
XPendingParams params) |
StreamPendingSummary |
xpending(String key,
String groupname)
XPENDING key group
|
List<StreamPendingEntry> |
xpending(String key,
String groupname,
StreamEntryID start,
StreamEntryID end,
int count,
String consumername)
XPENDING key group [start end count] [consumer]
|
List<StreamPendingEntry> |
xpending(String key,
String groupname,
XPendingParams params)
XPENDING key group [[IDLE min-idle-time] start end count [consumer]]
|
List<byte[]> |
xrange(byte[] key,
byte[] start,
byte[] end) |
List<byte[]> |
xrange(byte[] key,
byte[] start,
byte[] end,
int count) |
List<StreamEntry> |
xrange(String key,
StreamEntryID start,
StreamEntryID end)
XRANGE key start end
|
List<StreamEntry> |
xrange(String key,
StreamEntryID start,
StreamEntryID end,
int count)
XRANGE key start end COUNT count
|
List<StreamEntry> |
xrange(String key,
String start,
String end) |
List<StreamEntry> |
xrange(String key,
String start,
String end,
int count) |
List<byte[]> |
xread(XReadParams xReadParams,
Map.Entry<byte[],byte[]>... streams) |
List<Map.Entry<String,List<StreamEntry>>> |
xread(XReadParams xReadParams,
Map<String,StreamEntryID> streams)
XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]
|
List<byte[]> |
xreadGroup(byte[] groupname,
byte[] consumer,
XReadGroupParams xReadGroupParams,
Map.Entry<byte[],byte[]>... streams) |
List<Map.Entry<String,List<StreamEntry>>> |
xreadGroup(String groupname,
String consumer,
XReadGroupParams xReadGroupParams,
Map<String,StreamEntryID> streams)
XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]
|
List<byte[]> |
xrevrange(byte[] key,
byte[] end,
byte[] start) |
List<byte[]> |
xrevrange(byte[] key,
byte[] end,
byte[] start,
int count) |
List<StreamEntry> |
xrevrange(String key,
StreamEntryID end,
StreamEntryID start)
XREVRANGE key end start
|
List<StreamEntry> |
xrevrange(String key,
StreamEntryID end,
StreamEntryID start,
int count)
XREVRANGE key end start COUNT count
|
List<StreamEntry> |
xrevrange(String key,
String end,
String start) |
List<StreamEntry> |
xrevrange(String key,
String end,
String start,
int count) |
long |
xtrim(byte[] key,
long maxLen,
boolean approximateLength) |
long |
xtrim(byte[] key,
XTrimParams params) |
long |
xtrim(String key,
long maxLen,
boolean approximateLength)
XTRIM key MAXLEN [~] count
|
long |
xtrim(String key,
XTrimParams params)
XTRIM key MAXLEN|MINID [=|~] threshold [LIMIT count]
|
long |
zadd(byte[] key,
double score,
byte[] member)
Add the specified member having the specified score to the sorted set stored at key.
|
long |
zadd(byte[] key,
double score,
byte[] member,
ZAddParams params) |
long |
zadd(byte[] key,
Map<byte[],Double> scoreMembers) |
long |
zadd(byte[] key,
Map<byte[],Double> scoreMembers,
ZAddParams params) |
long |
zadd(String key,
double score,
String member)
Add the specified member having the specified score to the sorted set stored at key.
|
long |
zadd(String key,
double score,
String member,
ZAddParams params) |
long |
zadd(String key,
Map<String,Double> scoreMembers) |
long |
zadd(String key,
Map<String,Double> scoreMembers,
ZAddParams params) |
Double |
zaddIncr(byte[] key,
double score,
byte[] member,
ZAddParams params) |
Double |
zaddIncr(String key,
double score,
String member,
ZAddParams params) |
long |
zcard(byte[] key)
Return the sorted set cardinality (number of elements).
|
long |
zcard(String key)
Return the sorted set cardinality (number of elements).
|
long |
zcount(byte[] key,
byte[] min,
byte[] max) |
long |
zcount(byte[] key,
double min,
double max) |
long |
zcount(String key,
double min,
double max) |
long |
zcount(String key,
String min,
String max) |
Set<byte[]> |
zdiff(byte[]... keys) |
Set<String> |
zdiff(String... keys) |
long |
zdiffStore(byte[] dstkey,
byte[]... keys) |
long |
zdiffStore(String dstkey,
String... keys) |
Set<Tuple> |
zdiffWithScores(byte[]... keys) |
Set<Tuple> |
zdiffWithScores(String... keys) |
double |
zincrby(byte[] key,
double increment,
byte[] member)
If member already exists in the sorted set adds the increment to its score and updates the
position of the element in the sorted set accordingly.
|
Double |
zincrby(byte[] key,
double increment,
byte[] member,
ZIncrByParams params) |
double |
zincrby(String key,
double increment,
String member)
If member already exists in the sorted set adds the increment to its score and updates the
position of the element in the sorted set accordingly.
|
Double |
zincrby(String key,
double increment,
String member,
ZIncrByParams params) |
Set<byte[]> |
zinter(ZParams params,
byte[]... keys)
Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing
the resulting sorted set, it is returned to the connection.
|
Set<String> |
zinter(ZParams params,
String... keys)
Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing
the resulting sorted set, it is returned to the connection.
|
long |
zinterstore(byte[] dstkey,
byte[]... sets)
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at
dstkey.
|
long |
zinterstore(byte[] dstkey,
ZParams params,
byte[]... sets)
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at
dstkey.
|
long |
zinterstore(String dstkey,
String... sets)
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at
dstkey.
|
long |
zinterstore(String dstkey,
ZParams params,
String... sets)
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at
dstkey.
|
Set<Tuple> |
zinterWithScores(ZParams params,
byte[]... keys)
Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing
the resulting sorted set, it is returned to the connection.
|
Set<Tuple> |
zinterWithScores(ZParams params,
String... keys)
Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing
the resulting sorted set, it is returned to the connection.
|
long |
zlexcount(byte[] key,
byte[] min,
byte[] max) |
long |
zlexcount(String key,
String min,
String max) |
List<Double> |
zmscore(byte[] key,
byte[]... members)
Returns the scores associated with the specified members in the sorted set stored at key.
|
List<Double> |
zmscore(String key,
String... members)
Returns the scores associated with the specified members in the sorted set stored at key.
|
Tuple |
zpopmax(byte[] key) |
List<Tuple> |
zpopmax(byte[] key,
int count) |
Tuple |
zpopmax(String key) |
List<Tuple> |
zpopmax(String key,
int count) |
Tuple |
zpopmin(byte[] key) |
List<Tuple> |
zpopmin(byte[] key,
int count) |
Tuple |
zpopmin(String key) |
List<Tuple> |
zpopmin(String key,
int count) |
byte[] |
zrandmember(byte[] key) |
List<byte[]> |
zrandmember(byte[] key,
long count) |
String |
zrandmember(String key) |
List<String> |
zrandmember(String key,
long count) |
List<Tuple> |
zrandmemberWithScores(byte[] key,
long count) |
List<Tuple> |
zrandmemberWithScores(String key,
long count) |
List<byte[]> |
zrange(byte[] key,
long start,
long stop) |
List<String> |
zrange(String key,
long start,
long stop) |
List<byte[]> |
zrangeByLex(byte[] key,
byte[] min,
byte[] max) |
List<byte[]> |
zrangeByLex(byte[] key,
byte[] min,
byte[] max,
int offset,
int count) |
List<String> |
zrangeByLex(String key,
String min,
String max) |
List<String> |
zrangeByLex(String key,
String min,
String max,
int offset,
int count) |
List<byte[]> |
zrangeByScore(byte[] key,
byte[] min,
byte[] max) |
List<byte[]> |
zrangeByScore(byte[] key,
byte[] min,
byte[] max,
int offset,
int count) |
List<byte[]> |
zrangeByScore(byte[] key,
double min,
double max)
Return the all the elements in the sorted set at key with a score between min and max
(including elements with score equal to min or max).
|
List<byte[]> |
zrangeByScore(byte[] key,
double min,
double max,
int offset,
int count)
Return the all the elements in the sorted set at key with a score between min and max
(including elements with score equal to min or max).
|
List<String> |
zrangeByScore(String key,
double min,
double max)
Return the all the elements in the sorted set at key with a score between min and max
(including elements with score equal to min or max).
|
List<String> |
zrangeByScore(String key,
double min,
double max,
int offset,
int count)
Return the all the elements in the sorted set at key with a score between min and max
(including elements with score equal to min or max).
|
List<String> |
zrangeByScore(String key,
String min,
String max) |
List<String> |
zrangeByScore(String key,
String min,
String max,
int offset,
int count) |
List<Tuple> |
zrangeByScoreWithScores(byte[] key,
byte[] min,
byte[] max) |
List<Tuple> |
zrangeByScoreWithScores(byte[] key,
byte[] min,
byte[] max,
int offset,
int count) |
List<Tuple> |
zrangeByScoreWithScores(byte[] key,
double min,
double max)
Return the all the elements in the sorted set at key with a score between min and max
(including elements with score equal to min or max).
|
List<Tuple> |
zrangeByScoreWithScores(byte[] key,
double min,
double max,
int offset,
int count)
Return the all the elements in the sorted set at key with a score between min and max
(including elements with score equal to min or max).
|
List<Tuple> |
zrangeByScoreWithScores(String key,
double min,
double max)
Return the all the elements in the sorted set at key with a score between min and max
(including elements with score equal to min or max).
|
List<Tuple> |
zrangeByScoreWithScores(String key,
double min,
double max,
int offset,
int count)
Return the all the elements in the sorted set at key with a score between min and max
(including elements with score equal to min or max).
|
List<Tuple> |
zrangeByScoreWithScores(String key,
String min,
String max) |
List<Tuple> |
zrangeByScoreWithScores(String key,
String min,
String max,
int offset,
int count) |
List<Tuple> |
zrangeWithScores(byte[] key,
long start,
long stop) |
List<Tuple> |
zrangeWithScores(String key,
long start,
long stop) |
Long |
zrank(byte[] key,
byte[] member)
Return the rank (or index) or member in the sorted set at key, with scores being ordered from
low to high.
|
Long |
zrank(String key,
String member)
Return the rank (or index) of member in the sorted set at key, with scores being ordered from
low to high.
|
long |
zrem(byte[] key,
byte[]... members)
Remove the specified member from the sorted set value stored at key.
|
long |
zrem(String key,
String... members)
Remove the specified member from the sorted set value stored at key.
|
long |
zremrangeByLex(byte[] key,
byte[] min,
byte[] max) |
long |
zremrangeByLex(String key,
String min,
String max) |
long |
zremrangeByRank(byte[] key,
long start,
long stop)
Remove all elements in the sorted set at key with rank between start and end.
|
long |
zremrangeByRank(String key,
long start,
long stop)
Remove all elements in the sorted set at key with rank between start and end.
|
long |
zremrangeByScore(byte[] key,
byte[] min,
byte[] max) |
long |
zremrangeByScore(byte[] key,
double min,
double max)
Remove all the elements in the sorted set at key with a score between min and max (including
elements with score equal to min or max).
|
long |
zremrangeByScore(String key,
double min,
double max)
Remove all the elements in the sorted set at key with a score between min and max (including
elements with score equal to min or max).
|
long |
zremrangeByScore(String key,
String min,
String max) |
List<byte[]> |
zrevrange(byte[] key,
long start,
long stop) |
List<String> |
zrevrange(String key,
long start,
long stop) |
List<byte[]> |
zrevrangeByLex(byte[] key,
byte[] max,
byte[] min) |
List<byte[]> |
zrevrangeByLex(byte[] key,
byte[] max,
byte[] min,
int offset,
int count) |
List<String> |
zrevrangeByLex(String key,
String max,
String min) |
List<String> |
zrevrangeByLex(String key,
String max,
String min,
int offset,
int count) |
List<byte[]> |
zrevrangeByScore(byte[] key,
byte[] max,
byte[] min) |
List<byte[]> |
zrevrangeByScore(byte[] key,
byte[] max,
byte[] min,
int offset,
int count) |
List<byte[]> |
zrevrangeByScore(byte[] key,
double max,
double min) |
List<byte[]> |
zrevrangeByScore(byte[] key,
double max,
double min,
int offset,
int count) |
List<String> |
zrevrangeByScore(String key,
double max,
double min) |
List<String> |
zrevrangeByScore(String key,
double max,
double min,
int offset,
int count) |
List<String> |
zrevrangeByScore(String key,
String max,
String min) |
List<String> |
zrevrangeByScore(String key,
String max,
String min,
int offset,
int count) |
List<Tuple> |
zrevrangeByScoreWithScores(byte[] key,
byte[] max,
byte[] min) |
List<Tuple> |
zrevrangeByScoreWithScores(byte[] key,
byte[] max,
byte[] min,
int offset,
int count) |
List<Tuple> |
zrevrangeByScoreWithScores(byte[] key,
double max,
double min) |
List<Tuple> |
zrevrangeByScoreWithScores(byte[] key,
double max,
double min,
int offset,
int count) |
List<Tuple> |
zrevrangeByScoreWithScores(String key,
double max,
double min) |
List<Tuple> |
zrevrangeByScoreWithScores(String key,
double max,
double min,
int offset,
int count) |
List<Tuple> |
zrevrangeByScoreWithScores(String key,
String max,
String min) |
List<Tuple> |
zrevrangeByScoreWithScores(String key,
String max,
String min,
int offset,
int count) |
List<Tuple> |
zrevrangeWithScores(byte[] key,
long start,
long stop) |
List<Tuple> |
zrevrangeWithScores(String key,
long start,
long stop) |
Long |
zrevrank(byte[] key,
byte[] member)
Return the rank (or index) or member in the sorted set at key, with scores being ordered from
high to low.
|
Long |
zrevrank(String key,
String member)
Return the rank (or index) of member in the sorted set at key, with scores being ordered from
high to low.
|
ScanResult<Tuple> |
zscan(byte[] key,
byte[] cursor) |
ScanResult<Tuple> |
zscan(byte[] key,
byte[] cursor,
ScanParams params) |
ScanResult<Tuple> |
zscan(String key,
String cursor,
ScanParams params) |
Double |
zscore(byte[] key,
byte[] member)
Return the score of the specified element of the sorted set at key.
|
Double |
zscore(String key,
String member)
Return the score of the specified element of the sorted set at key.
|
Set<byte[]> |
zunion(ZParams params,
byte[]... keys)
Add multiple sorted sets, This command is similar to ZUNIONSTORE, but instead of storing the
resulting sorted set, it is returned to the connection.
|
Set<String> |
zunion(ZParams params,
String... keys)
Add multiple sorted sets, This command is similar to ZUNIONSTORE, but instead of storing the
resulting sorted set, it is returned to the connection.
|
long |
zunionstore(byte[] dstkey,
byte[]... sets)
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at
dstkey.
|
long |
zunionstore(byte[] dstkey,
ZParams params,
byte[]... sets)
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at
dstkey.
|
long |
zunionstore(String dstkey,
String... sets)
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at
dstkey.
|
long |
zunionstore(String dstkey,
ZParams params,
String... sets)
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at
dstkey.
|
Set<Tuple> |
zunionWithScores(ZParams params,
byte[]... keys)
Add multiple sorted sets with scores, This command is similar to ZUNIONSTORE, but instead of storing the
resulting sorted set, it is returned to the connection.
|
Set<Tuple> |
zunionWithScores(ZParams params,
String... keys)
Add multiple sorted sets with scores, This command is similar to ZUNIONSTORE, but instead of storing the
resulting sorted set, it is returned to the connection.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
hscan
sscan
zscan
xadd, xreadGroup
xadd
protected final Connection connection
protected static final byte[][] DUMMY_ARRAY
public Jedis()
public Jedis(String url)
JedisURIHelper.isValid(java.net.URI)
can be
used before this.url
- public Jedis(HostAndPort hp)
public Jedis(String host, int port)
public Jedis(String host, int port, JedisClientConfig config)
public Jedis(HostAndPort hostPort, JedisClientConfig config)
public Jedis(String host, int port, boolean ssl)
public Jedis(String host, int port, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier)
public Jedis(String host, int port, int timeout)
public Jedis(String host, int port, int timeout, boolean ssl)
public Jedis(String host, int port, int timeout, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier)
public Jedis(String host, int port, int connectionTimeout, int soTimeout)
public Jedis(String host, int port, int connectionTimeout, int soTimeout, int infiniteSoTimeout)
public Jedis(String host, int port, int connectionTimeout, int soTimeout, boolean ssl)
public Jedis(String host, int port, int connectionTimeout, int soTimeout, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier)
public Jedis(String host, int port, int connectionTimeout, int soTimeout, int infiniteSoTimeout, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier)
public Jedis(URI uri)
public Jedis(URI uri, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier)
public Jedis(URI uri, int timeout)
public Jedis(URI uri, int timeout, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier)
public Jedis(URI uri, int connectionTimeout, int soTimeout)
public Jedis(URI uri, int connectionTimeout, int soTimeout, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier)
public Jedis(URI uri, int connectionTimeout, int soTimeout, int infiniteSoTimeout, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier)
public Jedis(URI uri, JedisClientConfig config)
public Jedis(JedisSocketFactory jedisSocketFactory)
public Jedis(JedisSocketFactory jedisSocketFactory, JedisClientConfig clientConfig)
public Jedis(Connection connection)
public Connection getClient()
public Connection getConnection()
public void connect()
public void disconnect()
public boolean isConnected()
public boolean isBroken()
public void resetState()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public Transaction multi()
public Pipeline pipelined()
protected void checkIsInMultiOrPipeline()
public int getDB()
public boolean copy(byte[] srcKey, byte[] dstKey, int db, boolean replace)
copy
in interface DatabaseCommands
srcKey
- the source key.dstKey
- the destination key.db
- replace
- public boolean copy(byte[] srcKey, byte[] dstKey, boolean replace)
copy
in interface KeyBinaryCommands
srcKey
- the source key.dstKey
- the destination key.replace
- public String ping()
ServerCommands
ping
in interface ServerCommands
PONG
public byte[] ping(byte[] message)
ping()
but returns argument message instead of PONG
.message
- public String set(byte[] key, byte[] value)
Time complexity: O(1)
set
in interface StringBinaryCommands
key
- value
- public String set(byte[] key, byte[] value, SetParams params)
set
in interface StringBinaryCommands
key
- value
- params
- public byte[] get(byte[] key)
Time complexity: O(1)
get
in interface StringBinaryCommands
key
- public byte[] getDel(byte[] key)
Time complexity: O(1)
getDel
in interface StringBinaryCommands
key
- public byte[] getEx(byte[] key, GetExParams params)
getEx
in interface StringBinaryCommands
public String quit()
quit
in interface ServerCommands
public long exists(byte[]... keys)
exists
in interface KeyBinaryCommands
keys
- public boolean exists(byte[] key)
exists
in interface KeyBinaryCommands
key
- public long del(byte[]... keys)
del
in interface KeyBinaryCommands
keys
- public long del(byte[] key)
del
in interface KeyBinaryCommands
public long unlink(byte[]... keys)
Time complexity: O(1) for each key removed regardless of its size. Then the command does O(N) work in a different thread in order to reclaim memory, where N is the number of allocations the deleted objects where composed of.
unlink
in interface KeyBinaryCommands
keys
- public long unlink(byte[] key)
unlink
in interface KeyBinaryCommands
public String type(byte[] key)
type
in interface KeyBinaryCommands
key
- public String flushDB()
flushDB
in interface ServerCommands
public String flushDB(FlushMode flushMode)
flushDB
in interface DatabaseCommands
flushMode
- public Set<byte[]> keys(byte[] pattern)
Note that while the time complexity for this operation is O(n) the constant times are pretty low. For example Redis running on an entry level laptop can scan a 1 million keys database in 40 milliseconds. Still it's better to consider this one of the slow commands that may ruin the DB performance if not used with care.
In other words this command is intended only for debugging and special operations like creating a script to change the DB schema. Don't use it in your normal code. Use Redis Sets in order to group together a subset of objects.
Glob style patterns examples:
Use \ to escape special chars if you want to match them verbatim.
Time complexity: O(n) (with n being the number of keys in the DB, and assuming keys and pattern of limited length)
keys
in interface KeyBinaryCommands
pattern
- public byte[] randomBinaryKey()
Time complexity: O(1)
randomBinaryKey
in interface KeyBinaryCommands
public String rename(byte[] oldkey, byte[] newkey)
Time complexity: O(1)
rename
in interface KeyBinaryCommands
oldkey
- newkey
- public long renamenx(byte[] oldkey, byte[] newkey)
Time complexity: O(1)
renamenx
in interface KeyBinaryCommands
oldkey
- newkey
- public long dbSize()
dbSize
in interface DatabaseCommands
public long expire(byte[] key, long seconds)
Volatile keys are stored on disk like the other keys, the timeout is persistent too like all the other aspects of the dataset. Saving a dataset containing expires and stopping the server does not stop the flow of time as Redis stores on disk the time when the key will no longer be available as Unix time, and not the remaining seconds.
Since Redis 2.1.3 you can update the value of the timeout of a key already having an expire
set. It is also possible to undo the expire at all turning the key into a normal key using the
PERSIST
command.
Time complexity: O(1)
expire
in interface KeyBinaryCommands
key
- seconds
- public long expireAt(byte[] key, long unixTime)
EXPIRE
but instead to get the number of
seconds representing the Time To Live of the key as a second argument (that is a relative way
of specifying the TTL), it takes an absolute one in the form of a UNIX timestamp (Number of
seconds elapsed since 1 Gen 1970).
EXPIREAT was introduced in order to implement the Append Only File persistence mode so that EXPIRE commands are automatically translated into EXPIREAT commands for the append only file. Of course EXPIREAT can also used by programmers that need a way to simply specify that a given key should expire at a given time in the future.
Since Redis 2.1.3 you can update the value of the timeout of a key already having an expire
set. It is also possible to undo the expire at all turning the key into a normal key using the
PERSIST
command.
Time complexity: O(1)
expireAt
in interface KeyBinaryCommands
key
- unixTime
- public long ttl(byte[] key)
EXPIRE
set. This introspection capability allows a Redis connection to
check how many seconds a given key will continue to be part of the dataset.ttl
in interface KeyBinaryCommands
key
- public long touch(byte[]... keys)
touch
in interface KeyBinaryCommands
keys
- public long touch(byte[] key)
touch
in interface KeyBinaryCommands
public String select(int index)
select
in interface DatabaseCommands
index
- public String swapDB(int index1, int index2)
DatabaseCommands
swapDB
in interface DatabaseCommands
public long move(byte[] key, int dbIndex)
move
in interface DatabaseCommands
key
- dbIndex
- public String flushAll()
flushAll
in interface ServerCommands
public String flushAll(FlushMode flushMode)
flushAll
in interface ServerCommands
flushMode
- public byte[] getSet(byte[] key, byte[] value)
Time complexity: O(1)
getSet
in interface StringBinaryCommands
key
- value
- public List<byte[]> mget(byte[]... keys)
Time complexity: O(1) for every key
mget
in interface StringBinaryCommands
keys
- public long setnx(byte[] key, byte[] value)
SET
with the only difference that if the
key already exists no operation is performed. SETNX actually means "SET if Not eXists".
Time complexity: O(1)
setnx
in interface StringBinaryCommands
key
- value
- public String setex(byte[] key, long seconds, byte[] value)
SET
+ EXPIRE
. The operation is
atomic.
Time complexity: O(1)
setex
in interface StringBinaryCommands
key
- seconds
- value
- public String mset(byte[]... keysvalues)
MSETNX
will not perform any operation at all even if
just a single key already exists.
Because of this semantic MSETNX can be used in order to set different keys representing different fields of an unique logic object in a way that ensures that either all the fields or none at all are set.
Both MSET and MSETNX are atomic operations. This means that for instance if the keys A and B are modified, another connection talking to Redis can either see the changes to both A and B at once, or no modification at all.
mset
in interface StringBinaryCommands
keysvalues
- msetnx(byte[][])
public long msetnx(byte[]... keysvalues)
MSET
will
replace old values with new values, while MSETNX will not perform any operation at all even if
just a single key already exists.
Because of this semantic MSETNX can be used in order to set different keys representing different fields of an unique logic object in a way that ensures that either all the fields or none at all are set.
Both MSET and MSETNX are atomic operations. This means that for instance if the keys A and B are modified, another connection talking to Redis can either see the changes to both A and B at once, or no modification at all.
msetnx
in interface StringBinaryCommands
keysvalues
- mset(byte[][])
public long decrBy(byte[] key, long decrement)
INCR
but instead to decrement by 1 the decrement is
integer.
INCR commands are limited to 64 bit signed integers.
Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.
Time complexity: O(1)
decrBy
in interface StringBinaryCommands
key
- decrement
- incr(byte[])
,
decr(byte[])
,
incrBy(byte[], long)
public long decr(byte[] key)
INCR commands are limited to 64 bit signed integers.
Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.
Time complexity: O(1)
decr
in interface StringBinaryCommands
key
- incr(byte[])
,
incrBy(byte[], long)
,
decrBy(byte[], long)
public long incrBy(byte[] key, long increment)
INCR
but instead to increment by 1 the increment is
integer.
INCR commands are limited to 64 bit signed integers.
Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.
Time complexity: O(1)
incrBy
in interface StringBinaryCommands
key
- increment
- incr(byte[])
,
decr(byte[])
,
decrBy(byte[], long)
public double incrByFloat(byte[] key, double increment)
incrBy(byte[], long)
INCRBY} but increments by floats
instead of integers.
INCRBYFLOAT commands are limited to double precision floating point values.
Note: this is actually a string operation, that is, in Redis there are not "double" types. Simply the string stored at the key is parsed as a base double precision floating point value, incremented, and then converted back as a string. There is no DECRYBYFLOAT but providing a negative value will work as expected.
Time complexity: O(1)
incrByFloat
in interface StringBinaryCommands
key
- the key to incrementincrement
- the value to increment byincr(byte[])
,
decr(byte[])
,
decrBy(byte[], long)
public long incr(byte[] key)
INCR commands are limited to 64 bit signed integers.
Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.
Time complexity: O(1)
incr
in interface StringBinaryCommands
key
- incrBy(byte[], long)
,
decr(byte[])
,
decrBy(byte[], long)
public long append(byte[] key, byte[] value)
Time complexity: O(1). The amortized time complexity is O(1) assuming the appended value is small and the already present value is of any size, since the dynamic string library used by Redis will double the free space available on every reallocation.
append
in interface StringBinaryCommands
key
- value
- public byte[] substr(byte[] key, int start, int end)
The function handles out of range requests without raising an error, but just limiting the resulting range to the actual length of the string.
Time complexity: O(start+n) (with start being the start index and n the total length of the requested range). Note that the lookup part of this command is O(1) so for small strings this is actually an O(1) command.
substr
in interface StringBinaryCommands
key
- start
- end
- public long hset(byte[] key, byte[] field, byte[] value)
If key does not exist, a new key holding a hash is created.
Time complexity: O(1)
hset
in interface HashBinaryCommands
key
- field
- value
- public long hset(byte[] key, Map<byte[],byte[]> hash)
hset
in interface HashBinaryCommands
public byte[] hget(byte[] key, byte[] field)
If the field is not found or the key does not exist, a special 'nil' value is returned.
Time complexity: O(1)
hget
in interface HashBinaryCommands
key
- field
- public long hsetnx(byte[] key, byte[] field, byte[] value)
hsetnx
in interface HashBinaryCommands
key
- field
- value
- public String hmset(byte[] key, Map<byte[],byte[]> hash)
If key does not exist, a new key holding a hash is created.
Time complexity: O(N) (with N being the number of fields)
hmset
in interface HashBinaryCommands
key
- hash
- public List<byte[]> hmget(byte[] key, byte[]... fields)
If some of the specified fields do not exist, nil values are returned. Non existing keys are considered like empty hashes.
Time complexity: O(N) (with N being the number of fields)
hmget
in interface HashBinaryCommands
key
- fields
- public long hincrBy(byte[] key, byte[] field, long value)
The range of values supported by HINCRBY is limited to 64 bit signed integers.
Time complexity: O(1)
hincrBy
in interface HashBinaryCommands
key
- field
- value
- public double hincrByFloat(byte[] key, byte[] field, double value)
The range of values supported by HINCRBYFLOAT is limited to double precision floating point values.
Time complexity: O(1)
hincrByFloat
in interface HashBinaryCommands
key
- field
- value
- public boolean hexists(byte[] key, byte[] field)
hexists
in interface HashBinaryCommands
key
- field
- public long hdel(byte[] key, byte[]... fields)
Time complexity: O(1)
hdel
in interface HashBinaryCommands
key
- fields
- public long hlen(byte[] key)
Time complexity: O(1)
hlen
in interface HashBinaryCommands
key
- public Set<byte[]> hkeys(byte[] key)
Time complexity: O(N), where N is the total number of entries
hkeys
in interface HashBinaryCommands
key
- public List<byte[]> hvals(byte[] key)
Time complexity: O(N), where N is the total number of entries
hvals
in interface HashBinaryCommands
key
- public Map<byte[],byte[]> hgetAll(byte[] key)
Time complexity: O(N), where N is the total number of entries
hgetAll
in interface HashBinaryCommands
key
- public byte[] hrandfield(byte[] key)
Time complexity: O(N), where N is the number of fields returned
hrandfield
in interface HashBinaryCommands
key
- public List<byte[]> hrandfield(byte[] key, long count)
Time complexity: O(N), where N is the number of fields returned
hrandfield
in interface HashBinaryCommands
key
- public Map<byte[],byte[]> hrandfieldWithValues(byte[] key, long count)
Time complexity: O(N), where N is the number of fields returned
hrandfieldWithValues
in interface HashBinaryCommands
key
- public long rpush(byte[] key, byte[]... strings)
Time complexity: O(1)
rpush
in interface ListBinaryCommands
key
- strings
- public long lpush(byte[] key, byte[]... strings)
Time complexity: O(1)
lpush
in interface ListBinaryCommands
key
- strings
- public long llen(byte[] key)
Time complexity: O(1)
llen
in interface ListBinaryCommands
key
- public List<byte[]> lrange(byte[] key, long start, long stop)
For example LRANGE foobar 0 2 will return the first three elements of the list.
start and end can also be negative numbers indicating offsets from the end of the list. For example -1 is the last element of the list, -2 the penultimate element and so on.
Consistency with range functions in various programming languages
Note that if you have a list of numbers from 0 to 100, LRANGE 0 10 will return 11 elements, that is, rightmost item is included. This may or may not be consistent with behavior of range-related functions in your programming language of choice (think Ruby's Range.new, Array#slice or Python's range() function).
LRANGE behavior is consistent with one of Tcl.
Out-of-range indexes
Indexes out of range will not produce an error: if start is over the end of the list, or start > end, an empty list is returned. If end is over the end of the list Redis will threat it just like the last element of the list.
Time complexity: O(start+n) (with n being the length of the range and start being the start offset)
lrange
in interface ListBinaryCommands
key
- start
- stop
- public String ltrim(byte[] key, long start, long stop)
For example LTRIM foobar 0 2 will modify the list stored at foobar key so that only the first three elements of the list will remain.
start and end can also be negative numbers indicating offsets from the end of the list. For example -1 is the last element of the list, -2 the penultimate element and so on.
Indexes out of range will not produce an error: if start is over the end of the list, or start > end, an empty list is left as value. If end over the end of the list Redis will threat it just like the last element of the list.
Hint: the obvious use of LTRIM is together with LPUSH/RPUSH. For example:
lpush("mylist", "someelement"); ltrim("mylist", 0, 99); *
The above two commands will push elements in the list taking care that the list will not grow without limits. This is very useful when using Redis to store logs for example. It is important to note that when used in this way LTRIM is an O(1) operation because in the average case just one element is removed from the tail of the list.
Time complexity: O(n) (with n being len of list - len of range)
ltrim
in interface ListBinaryCommands
key
- start
- stop
- public byte[] lindex(byte[] key, long index)
If the value stored at key is not of list type an error is returned. If the index is out of range a 'nil' reply is returned.
Note that even if the average time complexity is O(n) asking for the first or the last element of the list is O(1).
Time complexity: O(n) (with n being the length of the list)
lindex
in interface ListBinaryCommands
key
- index
- public String lset(byte[] key, long index, byte[] value)
Out of range indexes will generate an error.
Similarly to other list commands accepting indexes, the index can be negative to access elements starting from the end of the list. So -1 is the last element, -2 is the penultimate, and so forth.
Time complexity:
O(N) (with N being the length of the list), setting the first or last elements of the list is O(1).
lset
in interface ListBinaryCommands
key
- index
- value
- lindex(byte[], long)
public long lrem(byte[] key, long count, byte[] value)
Time complexity: O(N) (with N being the length of the list)
lrem
in interface ListBinaryCommands
key
- count
- value
- public byte[] lpop(byte[] key)
If the key does not exist or the list is already empty the special value 'nil' is returned.
lpop
in interface ListBinaryCommands
key
- rpop(byte[])
public List<byte[]> lpop(byte[] key, int count)
lpop
in interface ListBinaryCommands
public Long lpos(byte[] key, byte[] element)
Time complexity: O(N) where N is the number of elements in the list
lpos
in interface ListBinaryCommands
key
- element
- lpos(byte[], byte[])
public Long lpos(byte[] key, byte[] element, LPosParams params)
Maxlen option compares the element provided only with a given maximum number of list items. A value of 1000 will make sure that the command performs only 1000 comparisons. The comparison is made for the first part or the last part depending on the fact we use a positive or negative rank. Following is how we could use the Maxlen option lpos("foo", "b", LPosParams.lPosParams().rank(1).maxlen(2)).
lpos
in interface ListBinaryCommands
key
- element
- params
- lpos(byte[], byte[], LPosParams)
public List<Long> lpos(byte[] key, byte[] element, LPosParams params, long count)
Time complexity: O(N) where N is the number of elements in the list
lpos
in interface ListBinaryCommands
key
- element
- params
- count
- lpos(byte[], byte[], LPosParams, long)
public byte[] rpop(byte[] key)
If the key does not exist or the list is already empty the special value 'nil' is returned.
rpop
in interface ListBinaryCommands
key
- lpop(byte[])
public List<byte[]> rpop(byte[] key, int count)
rpop
in interface ListBinaryCommands
public byte[] rpoplpush(byte[] srckey, byte[] dstkey)
If the key does not exist or the list is already empty the special value 'nil' is returned. If the srckey and dstkey are the same the operation is equivalent to removing the last element from the list and pushing it as first element of the list, so it's a "list rotation" command.
Time complexity: O(1)
rpoplpush
in interface ListBinaryCommands
srckey
- dstkey
- public long sadd(byte[] key, byte[]... members)
Time complexity O(1)
sadd
in interface SetBinaryCommands
key
- members
- public Set<byte[]> smembers(byte[] key)
#sinter(byte[]...)
SINTER}.
Time complexity O(N)
smembers
in interface SetBinaryCommands
key
- the key of the setpublic long srem(byte[] key, byte[]... member)
Time complexity O(1)
srem
in interface SetBinaryCommands
key
- the key of the setmember
- the set member to removepublic byte[] spop(byte[] key)
The srandmember(byte[])
command does a similar work but the returned element is not
removed from the Set.
Time complexity O(1)
spop
in interface SetBinaryCommands
key
- public Set<byte[]> spop(byte[] key, long count)
spop
in interface SetBinaryCommands
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.
Time complexity O(1)
smove
in interface SetBinaryCommands
srckey
- dstkey
- member
- public long scard(byte[] key)
scard
in interface SetBinaryCommands
key
- public boolean sismember(byte[] key, byte[] member)
Time complexity O(1)
sismember
in interface SetBinaryCommands
key
- member
- public List<Boolean> smismember(byte[] key, byte[]... members)
Time complexity O(N) where N is the number of elements being checked for membership
smismember
in interface SetBinaryCommands
key
- members
- public Set<byte[]> sinter(byte[]... keys)
lrange(byte[], long, long)
LRANGE} the result is sent to the
connection 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).
Time complexity O(N*M) worst case where N is the cardinality of the smallest set and M the number of sets
sinter
in interface SetBinaryCommands
keys
- public long sinterstore(byte[] dstkey, byte[]... keys)
SINTER
but instead of being returned
the resulting set is stored as dstkey.
Time complexity O(N*M) worst case where N is the cardinality of the smallest set and M the number of sets
sinterstore
in interface SetBinaryCommands
dstkey
- keys
- public Set<byte[]> sunion(byte[]... keys)
lrange(byte[], long, long)
LRANGE} the result is sent to the connection 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.
Time complexity O(N) where N is the total number of elements in all the provided sets
sunion
in interface SetBinaryCommands
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.
Time complexity O(N) where N is the total number of elements in all the provided sets
sunionstore
in interface SetBinaryCommands
dstkey
- keys
- 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:
O(N) with N being the total number of elements of all the sets
sdiff
in interface SetBinaryCommands
keys
- public long sdiffstore(byte[] dstkey, byte[]... keys)
SDIFF
but instead of being returned
the resulting set is stored in dstkey.sdiffstore
in interface SetBinaryCommands
dstkey
- keys
- public byte[] srandmember(byte[] key)
The SPOP command does a similar work but the returned element is popped (removed) from the Set.
Time complexity O(1)
srandmember
in interface SetBinaryCommands
key
- public List<byte[]> srandmember(byte[] key, int count)
srandmember
in interface SetBinaryCommands
public long zadd(byte[] key, double score, byte[] member)
The score value can be the string representation of a double precision floating point number.
Time complexity O(log(N)) with N being the number of elements in the sorted set
zadd
in interface SortedSetBinaryCommands
key
- score
- member
- public long zadd(byte[] key, double score, byte[] member, ZAddParams params)
zadd
in interface SortedSetBinaryCommands
public long zadd(byte[] key, Map<byte[],Double> scoreMembers)
zadd
in interface SortedSetBinaryCommands
public long zadd(byte[] key, Map<byte[],Double> scoreMembers, ZAddParams params)
zadd
in interface SortedSetBinaryCommands
public Double zaddIncr(byte[] key, double score, byte[] member, ZAddParams params)
zaddIncr
in interface SortedSetBinaryCommands
public List<byte[]> zrange(byte[] key, long start, long stop)
zrange
in interface SortedSetBinaryCommands
public long zrem(byte[] key, byte[]... members)
Time complexity O(log(N)) with N being the number of elements in the sorted set
zrem
in interface SortedSetBinaryCommands
key
- members
- public double zincrby(byte[] key, double increment, byte[] member)
The score value can be the string representation of a double precision floating point number. It's possible to provide a negative value to perform a decrement.
For an introduction to sorted sets check the Introduction to Redis data types page.
Time complexity O(log(N)) with N being the number of elements in the sorted set
zincrby
in interface SortedSetBinaryCommands
key
- increment
- member
- public Double zincrby(byte[] key, double increment, byte[] member, ZIncrByParams params)
zincrby
in interface SortedSetBinaryCommands
public Long zrank(byte[] key, byte[] member)
When the given member does not exist in the sorted set, the special value 'nil' is returned. The returned rank (or index) of the member is 0-based for both commands.
Time complexity:
O(log(N))
zrank
in interface SortedSetBinaryCommands
key
- member
- zrevrank(byte[], byte[])
public Long zrevrank(byte[] key, byte[] member)
When the given member does not exist in the sorted set, the special value 'nil' is returned. The returned rank (or index) of the member is 0-based for both commands.
Time complexity:
O(log(N))
zrevrank
in interface SortedSetBinaryCommands
key
- member
- zrank(byte[], byte[])
public List<byte[]> zrevrange(byte[] key, long start, long stop)
zrevrange
in interface SortedSetBinaryCommands
public List<Tuple> zrangeWithScores(byte[] key, long start, long stop)
zrangeWithScores
in interface SortedSetBinaryCommands
public List<Tuple> zrevrangeWithScores(byte[] key, long start, long stop)
zrevrangeWithScores
in interface SortedSetBinaryCommands
public byte[] zrandmember(byte[] key)
zrandmember
in interface SortedSetBinaryCommands
public List<byte[]> zrandmember(byte[] key, long count)
zrandmember
in interface SortedSetBinaryCommands
public List<Tuple> zrandmemberWithScores(byte[] key, long count)
zrandmemberWithScores
in interface SortedSetBinaryCommands
public long zcard(byte[] key)
Time complexity O(1)
zcard
in interface SortedSetBinaryCommands
key
- public Double zscore(byte[] key, byte[] member)
Time complexity: O(1)
zscore
in interface SortedSetBinaryCommands
key
- member
- public List<Double> zmscore(byte[] key, byte[]... members)
Time complexity: O(N) where N is the number of members being requested.
zmscore
in interface SortedSetBinaryCommands
key
- members
- public Tuple zpopmax(byte[] key)
zpopmax
in interface SortedSetBinaryCommands
public List<Tuple> zpopmax(byte[] key, int count)
zpopmax
in interface SortedSetBinaryCommands
public Tuple zpopmin(byte[] key)
zpopmin
in interface SortedSetBinaryCommands
public List<Tuple> zpopmin(byte[] key, int count)
zpopmin
in interface SortedSetBinaryCommands
public String watch(byte[]... keys)
public String unwatch()
public List<byte[]> sort(byte[] key)
Sort the elements contained in the List, Set, or Sorted Set value at key. By default sorting is numeric with elements being compared as double precision floating point numbers. This is the simplest form of SORT.
sort
in interface KeyBinaryCommands
key
- sort(byte[], byte[])
,
sort(byte[], SortingParams)
,
sort(byte[], SortingParams, byte[])
public List<byte[]> sort(byte[] key, SortingParams sortingParameters)
examples:
Given are the following sets and key/values:
x = [1, 2, 3] y = [a, b, c] k1 = z k2 = y k3 = x w1 = 9 w2 = 8 w3 = 7Sort Order:
sort(x) or sort(x, sp.asc()) -> [1, 2, 3] sort(x, sp.desc()) -> [3, 2, 1] sort(y) -> [c, a, b] sort(y, sp.alpha()) -> [a, b, c] sort(y, sp.alpha().desc()) -> [c, a, b]Limit (e.g. for Pagination):
sort(x, sp.limit(0, 2)) -> [1, 2] sort(y, sp.alpha().desc().limit(1, 2)) -> [b, a]Sorting by external keys:
sort(x, sb.by(w*)) -> [3, 2, 1] sort(x, sb.by(w*).desc()) -> [1, 2, 3]Getting external keys:
sort(x, sp.by(w*).get(k*)) -> [x, y, z] sort(x, sp.by(w*).get(#).get(k*)) -> [3, x, 2, y, 1, z]
sort
in interface KeyBinaryCommands
key
- sortingParameters
- sort(byte[])
,
sort(byte[], SortingParams, byte[])
public long sort(byte[] key, SortingParams sortingParameters, byte[] dstkey)
sort
in interface KeyBinaryCommands
key
- sortingParameters
- dstkey
- sort(byte[], SortingParams)
,
sort(byte[])
,
sort(byte[], byte[])
public long sort(byte[] key, byte[] dstkey)
Sort the elements contained in the List, Set, or Sorted Set value at key and store the result at dstkey. By default sorting is numeric with elements being compared as double precision floating point numbers. This is the simplest form of SORT.
sort
in interface KeyBinaryCommands
key
- dstkey
- sort(byte[])
,
sort(byte[], SortingParams)
,
sort(byte[], SortingParams, byte[])
public byte[] lmove(byte[] srcKey, byte[] dstKey, ListDirection from, ListDirection to)
lmove
in interface ListBinaryCommands
srcKey
- dstKey
- from
- to
- public byte[] blmove(byte[] srcKey, byte[] dstKey, ListDirection from, ListDirection to, double timeout)
blmove
in interface ListBinaryCommands
srcKey
- dstKey
- from
- to
- timeout
- public List<byte[]> blpop(int timeout, byte[]... keys)
The following is a description of the exact semantic. We describe BLPOP but the two commands are identical, the only difference is that BLPOP pops the element from the left (head) of the list, and BRPOP pops from the right (tail).
Non blocking behavior
When BLPOP is called, if at least one of the specified keys contain a non empty list, an element is popped from the head of the list and returned to the caller together with the name of the key (BLPOP returns a two elements array, the first element is the key, the second the popped value).
Keys are scanned from left to right, so for instance if you issue BLPOP list1 list2 list3 0 against a dataset where list1 does not exist but list2 and list3 contain non empty lists, BLPOP guarantees to return an element from the list stored at list2 (since it is the first non empty list starting from the left).
Blocking behavior
If none of the specified keys exist or contain non empty lists, BLPOP blocks until some other connection performs a LPUSH or an RPUSH operation against one of the lists.
Once new data is present on one of the lists, the connection finally returns with the name of the key unblocking it and the popped value.
When blocking, if a non-zero timeout is specified, the connection will unblock returning a nil special value if the specified amount of seconds passed without a push operation against at least one of the specified keys.
The timeout argument is interpreted as an integer value. A timeout of zero means instead to block forever.
Multiple clients blocking for the same keys
Multiple clients can block for the same key. They are put into a queue, so the first to be served will be the one that started to wait earlier, in a first-blpopping first-served fashion.
blocking POP inside a MULTI/EXEC transaction
BLPOP and BRPOP can be used with pipelining (sending multiple commands and reading the replies in batch), but it does not make sense to use BLPOP or BRPOP inside a MULTI/EXEC block (a Redis transaction).
The behavior of BLPOP inside MULTI/EXEC when the list is empty is to return a multi-bulk nil reply, exactly what happens when the timeout is reached. If you like science fiction, think at it like if inside MULTI/EXEC the time will flow at infinite speed :)
Time complexity: O(1)
blpop
in interface ListBinaryCommands
timeout
- keys
- When a non-zero timeout is specified, and the BLPOP operation timed out, the return value is a nil multi bulk reply. Most connection values will return false or nil accordingly to the programming language used.
public List<byte[]> blpop(double timeout, byte[]... keys)
blpop
in interface ListBinaryCommands
public List<byte[]> brpop(int timeout, byte[]... keys)
The following is a description of the exact semantic. We describe BLPOP but the two commands are identical, the only difference is that BLPOP pops the element from the left (head) of the list, and BRPOP pops from the right (tail).
Non blocking behavior
When BLPOP is called, if at least one of the specified keys contain a non empty list, an element is popped from the head of the list and returned to the caller together with the name of the key (BLPOP returns a two elements array, the first element is the key, the second the popped value).
Keys are scanned from left to right, so for instance if you issue BLPOP list1 list2 list3 0 against a dataset where list1 does not exist but list2 and list3 contain non empty lists, BLPOP guarantees to return an element from the list stored at list2 (since it is the first non empty list starting from the left).
Blocking behavior
If none of the specified keys exist or contain non empty lists, BLPOP blocks until some other connection performs a LPUSH or an RPUSH operation against one of the lists.
Once new data is present on one of the lists, the connection finally returns with the name of the key unblocking it and the popped value.
When blocking, if a non-zero timeout is specified, the connection will unblock returning a nil special value if the specified amount of seconds passed without a push operation against at least one of the specified keys.
The timeout argument is interpreted as an integer value. A timeout of zero means instead to block forever.
Multiple clients blocking for the same keys
Multiple clients can block for the same key. They are put into a queue, so the first to be served will be the one that started to wait earlier, in a first-blpopping first-served fashion.
blocking POP inside a MULTI/EXEC transaction
BLPOP and BRPOP can be used with pipelining (sending multiple commands and reading the replies in batch), but it does not make sense to use BLPOP or BRPOP inside a MULTI/EXEC block (a Redis transaction).
The behavior of BLPOP inside MULTI/EXEC when the list is empty is to return a multi-bulk nil reply, exactly what happens when the timeout is reached. If you like science fiction, think at it like if inside MULTI/EXEC the time will flow at infinite speed :)
Time complexity: O(1)
brpop
in interface ListBinaryCommands
timeout
- keys
- When a non-zero timeout is specified, and the BLPOP operation timed out, the return value is a nil multi bulk reply. Most connection values will return false or nil accordingly to the programming language used.
public List<byte[]> brpop(double timeout, byte[]... keys)
brpop
in interface ListBinaryCommands
public List<byte[]> bzpopmax(double timeout, byte[]... keys)
bzpopmax
in interface SortedSetBinaryCommands
public List<byte[]> bzpopmin(double timeout, byte[]... keys)
bzpopmin
in interface SortedSetBinaryCommands
public String auth(String password)
auth
in interface ServerCommands
password
- public String auth(String user, String password)
auth
in interface ServerCommands
user
- password
- public long zcount(byte[] key, double min, double max)
zcount
in interface SortedSetBinaryCommands
public long zcount(byte[] key, byte[] min, byte[] max)
zcount
in interface SortedSetBinaryCommands
public Set<byte[]> zdiff(byte[]... keys)
zdiff
in interface SortedSetBinaryCommands
public Set<Tuple> zdiffWithScores(byte[]... keys)
zdiffWithScores
in interface SortedSetBinaryCommands
public long zdiffStore(byte[] dstkey, byte[]... keys)
zdiffStore
in interface SortedSetBinaryCommands
public List<byte[]> zrangeByScore(byte[] key, double min, double max)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional LIMIT
it's possible
to get only a range of the matching elements in an SQL-alike way. Note that if offset is large
the commands needs to traverse the list for offset elements and this adds up to the O(M)
figure.
The ZCOUNT
command is similar to
ZRANGEBYSCORE
but instead of returning the
actual elements in the specified interval, it just returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
zrangeByScore
in interface SortedSetBinaryCommands
key
- min
- max
- zrangeByScore(byte[], double, double)
,
zrangeByScore(byte[], double, double, int, int)
,
zrangeByScoreWithScores(byte[], double, double)
,
zrangeByScoreWithScores(byte[], double, double, int, int)
,
zcount(byte[], double, double)
public List<byte[]> zrangeByScore(byte[] key, byte[] min, byte[] max)
zrangeByScore
in interface SortedSetBinaryCommands
public List<byte[]> zrangeByScore(byte[] key, double min, double max, int offset, int count)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional LIMIT
it's possible
to get only a range of the matching elements in an SQL-alike way. Note that if offset is large
the commands needs to traverse the list for offset elements and this adds up to the O(M)
figure.
The ZCOUNT
command is similar to
ZRANGEBYSCORE
but instead of returning the
actual elements in the specified interval, it just returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
zrangeByScore
in interface SortedSetBinaryCommands
key
- min
- max
- offset
- count
- zrangeByScore(byte[], double, double)
,
zrangeByScore(byte[], double, double, int, int)
,
zrangeByScoreWithScores(byte[], double, double)
,
zrangeByScoreWithScores(byte[], double, double, int, int)
,
zcount(byte[], double, double)
public List<byte[]> zrangeByScore(byte[] key, byte[] min, byte[] max, int offset, int count)
zrangeByScore
in interface SortedSetBinaryCommands
public List<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional LIMIT
it's possible
to get only a range of the matching elements in an SQL-alike way. Note that if offset is large
the commands needs to traverse the list for offset elements and this adds up to the O(M)
figure.
The ZCOUNT
command is similar to
ZRANGEBYSCORE
but instead of returning the
actual elements in the specified interval, it just returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
zrangeByScoreWithScores
in interface SortedSetBinaryCommands
key
- min
- max
- zrangeByScore(byte[], double, double)
,
zrangeByScore(byte[], double, double, int, int)
,
zrangeByScoreWithScores(byte[], double, double)
,
zrangeByScoreWithScores(byte[], double, double, int, int)
,
zcount(byte[], double, double)
public List<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max)
zrangeByScoreWithScores
in interface SortedSetBinaryCommands
public List<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max, int offset, int count)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional LIMIT
it's possible
to get only a range of the matching elements in an SQL-alike way. Note that if offset is large
the commands needs to traverse the list for offset elements and this adds up to the O(M)
figure.
The ZCOUNT
command is similar to
ZRANGEBYSCORE
but instead of returning the
actual elements in the specified interval, it just returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
zrangeByScoreWithScores
in interface SortedSetBinaryCommands
key
- min
- max
- offset
- count
- zrangeByScore(byte[], double, double)
,
zrangeByScore(byte[], double, double, int, int)
,
zrangeByScoreWithScores(byte[], double, double)
,
zrangeByScoreWithScores(byte[], double, double, int, int)
,
zcount(byte[], double, double)
public List<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max, int offset, int count)
zrangeByScoreWithScores
in interface SortedSetBinaryCommands
public List<byte[]> zrevrangeByScore(byte[] key, double max, double min)
zrevrangeByScore
in interface SortedSetBinaryCommands
public List<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min)
zrevrangeByScore
in interface SortedSetBinaryCommands
public List<byte[]> zrevrangeByScore(byte[] key, double max, double min, int offset, int count)
zrevrangeByScore
in interface SortedSetBinaryCommands
public List<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min, int offset, int count)
zrevrangeByScore
in interface SortedSetBinaryCommands
public List<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min)
zrevrangeByScoreWithScores
in interface SortedSetBinaryCommands
public List<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min, int offset, int count)
zrevrangeByScoreWithScores
in interface SortedSetBinaryCommands
public List<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min)
zrevrangeByScoreWithScores
in interface SortedSetBinaryCommands
public List<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min, int offset, int count)
zrevrangeByScoreWithScores
in interface SortedSetBinaryCommands
public long zremrangeByRank(byte[] key, long start, long stop)
Time complexity: O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements removed by the operation
zremrangeByRank
in interface SortedSetBinaryCommands
key
- start
- stop
- public long zremrangeByScore(byte[] key, double min, double max)
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements removed by the operation
zremrangeByScore
in interface SortedSetBinaryCommands
key
- min
- max
- public long zremrangeByScore(byte[] key, byte[] min, byte[] max)
zremrangeByScore
in interface SortedSetBinaryCommands
public Set<byte[]> zunion(ZParams params, byte[]... keys)
zunion
in interface SortedSetBinaryCommands
params
- keys
- public Set<Tuple> zunionWithScores(ZParams params, byte[]... keys)
zunionWithScores
in interface SortedSetBinaryCommands
params
- keys
- public long zunionstore(byte[] dstkey, byte[]... sets)
As the terms imply, the #zinterstore(byte[], byte[]...)
ZINTERSTORE} command requires
an element to be present in each of the given inputs to be inserted in the result. The #zunionstore(byte[], byte[]...)
command inserts all elements across all inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
zunionstore
in interface SortedSetBinaryCommands
dstkey
- sets
- public long zunionstore(byte[] dstkey, ZParams params, byte[]... sets)
As the terms imply, the ZINTERSTORE
command requires an
element to be present in each of the given inputs to be inserted in the result. The ZUNIONSTORE
command inserts all elements across all inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
zunionstore
in interface SortedSetBinaryCommands
dstkey
- sets
- params
- public Set<byte[]> zinter(ZParams params, byte[]... keys)
zinter
in interface SortedSetBinaryCommands
params
- keys
- public Set<Tuple> zinterWithScores(ZParams params, byte[]... keys)
zinterWithScores
in interface SortedSetBinaryCommands
params
- keys
- public long zinterstore(byte[] dstkey, byte[]... sets)
As the terms imply, the ZINTERSTORE
command requires an
element to be present in each of the given inputs to be inserted in the result. The ZUNIONSTORE
command inserts all elements across all inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
zinterstore
in interface SortedSetBinaryCommands
dstkey
- sets
- public long zinterstore(byte[] dstkey, ZParams params, byte[]... sets)
As the terms imply, the ZINTERSTORE
command requires an
element to be present in each of the given inputs to be inserted in the result. The ZUNIONSTORE
command inserts all elements across all inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
zinterstore
in interface SortedSetBinaryCommands
dstkey
- sets
- params
- public long zlexcount(byte[] key, byte[] min, byte[] max)
zlexcount
in interface SortedSetBinaryCommands
public List<byte[]> zrangeByLex(byte[] key, byte[] min, byte[] max)
zrangeByLex
in interface SortedSetBinaryCommands
public List<byte[]> zrangeByLex(byte[] key, byte[] min, byte[] max, int offset, int count)
zrangeByLex
in interface SortedSetBinaryCommands
public List<byte[]> zrevrangeByLex(byte[] key, byte[] max, byte[] min)
zrevrangeByLex
in interface SortedSetBinaryCommands
public List<byte[]> zrevrangeByLex(byte[] key, byte[] max, byte[] min, int offset, int count)
zrevrangeByLex
in interface SortedSetBinaryCommands
public long zremrangeByLex(byte[] key, byte[] min, byte[] max)
zremrangeByLex
in interface SortedSetBinaryCommands
public String save()
Save the whole dataset on disk (this means that all the databases are saved, as well as keys with an EXPIRE set (the expire is preserved). The server hangs while the saving is not completed, no connection is served in the meanwhile. An OK code is returned when the DB was fully stored in disk.
The background variant of this command is BGSAVE
that is able to perform the
saving in the background while the server continues serving other clients.
save
in interface ServerCommands
public String bgsave()
Save the DB in background. The OK code is immediately returned. Redis forks, the parent continues to server the clients, the child saves the DB on disk then exit. A connection my be able to check if the operation succeeded using the LASTSAVE command.
bgsave
in interface ServerCommands
public String bgrewriteaof()
BGREWRITEAOF rewrites the Append Only File in background when it gets too big. The Redis Append Only File is a Journal, so every operation modifying the dataset is logged in the Append Only File (and replayed at startup). This means that the Append Only File always grows. In order to rebuild its content the BGREWRITEAOF creates a new version of the append only file starting directly form the dataset in memory in order to guarantee the generation of the minimal number of commands needed to rebuild the database.
bgrewriteaof
in interface ServerCommands
public long lastsave()
Return the UNIX TIME of the last DB save executed with success. A connection may check if a
BGSAVE
command succeeded reading the LASTSAVE value, then issuing a BGSAVE
command and checking at regular intervals every N seconds if LASTSAVE changed.
lastsave
in interface ServerCommands
public void shutdown() throws JedisException
Stop all the clients, save the DB, then quit the server. This commands makes sure that the DB
is switched off without the lost of any data. This is not guaranteed if the connection uses
simply SAVE
and then QUIT
because other clients may alter the
DB data between the two commands.
shutdown
in interface ServerCommands
JedisException
- with the status code reply on error. On success nothing is thrown since
the server quits and the connection is closed.public void shutdown(SaveMode saveMode) throws JedisException
shutdown
in interface ServerCommands
saveMode
- modifier to alter the data save behavior of SHUTDOWN. null
would
trigger the default behavior.JedisException
SaveMode
public String info()
The info command returns different information and statistics about the server in an format that's simple to parse by computers and easy to read by humans.
Format of the returned String:
All the fields are in the form field:value
edis_version:0.07 connected_clients:1 connected_slaves:0 used_memory:3187 changes_since_last_save:0 last_save_time:1237655729 total_connections_received:1 total_commands_processed:1 uptime_in_seconds:25 uptime_in_days:0Notes
used_memory is returned in bytes, and is the total number of bytes allocated by the program using malloc.
uptime_in_days is redundant since the uptime in seconds contains already the full uptime information, this field is only mainly present for humans.
changes_since_last_save does not refer to the number of key changes, but to the number of operations that produced some kind of change in the dataset.
info
in interface ServerCommands
public String info(String section)
ServerCommands
info
in interface ServerCommands
section
- (all: Return all sections, default: Return only the default set of sections,
server: General information about the Redis server, clients: Client connections
section, memory: Memory consumption related information, persistence: RDB and AOF
related information, stats: General statistics, replication: Master/slave replication
information, cpu: CPU consumption statistics, commandstats: Redis command statistics,
cluster: Redis Cluster section, keyspace: Database related statistics)public void monitor(JedisMonitor jedisMonitor)
MONITOR is a debugging command that outputs the whole sequence of commands received by the Redis server. is very handy in order to understand what is happening into the database. This command is used directly via telnet.
jedisMonitor
- public String slaveof(String host, int port)
The SLAVEOF command can change the replication settings of a slave on the fly. If a Redis server is already acting as slave, the command SLAVEOF NO ONE will turn off the replication turning the Redis server into a MASTER. In the proper form SLAVEOF hostname port will make the server a slave of the specific server listening at the specified hostname and port.
If a server is already a slave of some master, SLAVEOF hostname port will stop the replication against the old server and start the synchronization against the new one discarding the old dataset.
The form SLAVEOF no one will stop replication turning the server into a MASTER but will not discard the replication. So if the old master stop working it is possible to turn the slave into a master and set the application to use the new master in read/write. Later when the other Redis server will be fixed it can be configured in order to work as slave.
slaveof
in interface ServerCommands
host
- port
- public String slaveofNoOne()
ServerCommands
slaveofNoOne
in interface ServerCommands
public List<Object> roleBinary()
roleBinary
in interface ControlBinaryCommands
public List<byte[]> configGet(byte[] pattern)
CONFIG GET returns the current configuration parameters. This sub command only accepts a single argument, that is glob style pattern. All the configuration parameters matching this parameter are reported as a list of key-value pairs.
Example:
$ redis-cli config get '*' 1. "dbfilename" 2. "dump.rdb" 3. "requirepass" 4. (nil) 5. "masterauth" 6. (nil) 7. "maxmemory" 8. "0\n" 9. "appendfsync" 10. "everysec" 11. "save" 12. "3600 1 300 100 60 10000" $ redis-cli config get 'm*' 1. "masterauth" 2. (nil) 3. "maxmemory" 4. "0\n"
configGet
in interface ConfigCommands
pattern
- public String configResetStat()
configResetStat
in interface ConfigCommands
public String configRewrite()
The rewrite is performed in a very conservative way:
CONFIG REWRITE is also able to rewrite the configuration file from scratch if the original one no longer exists for some reason. However if the server was started without a configuration file at all, the CONFIG REWRITE will just return an error.
configRewrite
in interface ConfigCommands
public String configSet(byte[] parameter, byte[] value)
The list of configuration parameters supported by CONFIG SET can be obtained issuing a
CONFIG GET *
command.
The configuration set using CONFIG SET is immediately loaded by the Redis server that will start acting as specified starting from the next command.
Parameters value format
The value of the configuration parameter is the same as the one of the same parameter in the Redis configuration file, with the following exceptions:
configSet
in interface ConfigCommands
parameter
- value
- public long strlen(byte[] key)
strlen
in interface StringBinaryCommands
public LCSMatchResult strAlgoLCSKeys(byte[] keyA, byte[] keyB, StrAlgoLCSParams params)
strAlgoLCSKeys
in interface StringBinaryCommands
public LCSMatchResult strAlgoLCSStrings(byte[] strA, byte[] strB, StrAlgoLCSParams params)
public long lpushx(byte[] key, byte[]... string)
lpushx
in interface ListBinaryCommands
public long persist(byte[] key)
expire
at turning the expire key into a normal key.
Time complexity: O(1)
persist
in interface KeyBinaryCommands
key
- public long rpushx(byte[] key, byte[]... string)
rpushx
in interface ListBinaryCommands
public byte[] echo(byte[] string)
echo
in interface ServerCommands
public long linsert(byte[] key, ListPosition where, byte[] pivot, byte[] value)
linsert
in interface ListBinaryCommands
public byte[] brpoplpush(byte[] source, byte[] destination, int timeout)
brpoplpush
in interface ListBinaryCommands
public boolean setbit(byte[] key, long offset, boolean value)
setbit
in interface StringBinaryCommands
public boolean getbit(byte[] key, long offset)
getbit
in interface StringBinaryCommands
public long bitpos(byte[] key, boolean value)
bitpos
in interface StringBinaryCommands
public long bitpos(byte[] key, boolean value, BitPosParams params)
bitpos
in interface StringBinaryCommands
public long setrange(byte[] key, long offset, byte[] value)
setrange
in interface StringBinaryCommands
public byte[] getrange(byte[] key, long startOffset, long endOffset)
getrange
in interface StringBinaryCommands
public long publish(byte[] channel, byte[] message)
public void subscribe(BinaryJedisPubSub jedisPubSub, byte[]... channels)
public void psubscribe(BinaryJedisPubSub jedisPubSub, byte[]... patterns)
public Object eval(byte[] script, List<byte[]> keys, List<byte[]> args)
eval
in interface ScriptingKeyBinaryCommands
script
- keys
- args
- protected static byte[][] getParamsWithBinary(List<byte[]> keys, List<byte[]> args)
public Object eval(byte[] script, int keyCount, byte[]... params)
eval
in interface ScriptingKeyBinaryCommands
public Object eval(byte[] script)
eval
in interface ScriptingKeyBinaryCommands
public Object evalsha(byte[] sha1)
evalsha
in interface ScriptingKeyBinaryCommands
public Object evalsha(byte[] sha1, List<byte[]> keys, List<byte[]> args)
evalsha
in interface ScriptingKeyBinaryCommands
public Object evalsha(byte[] sha1, int keyCount, byte[]... params)
evalsha
in interface ScriptingKeyBinaryCommands
public String scriptFlush()
scriptFlush
in interface ScriptingControlCommands
public String scriptFlush(FlushMode flushMode)
scriptFlush
in interface ScriptingControlCommands
public Boolean scriptExists(byte[] sha1)
scriptExists
in interface ScriptingControlCommands
public List<Boolean> scriptExists(byte[]... sha1)
scriptExists
in interface ScriptingControlCommands
public byte[] scriptLoad(byte[] script)
scriptLoad
in interface ScriptingControlCommands
public String scriptKill()
scriptKill
in interface ScriptingControlCommands
public String slowlogReset()
slowlogReset
in interface SlowlogCommands
public long slowlogLen()
slowlogLen
in interface SlowlogCommands
public List<Object> slowlogGetBinary()
slowlogGetBinary
in interface SlowlogCommands
public List<Object> slowlogGetBinary(long entries)
slowlogGetBinary
in interface SlowlogCommands
public Long objectRefcount(byte[] key)
objectRefcount
in interface ControlBinaryCommands
objectRefcount
in interface KeyBinaryCommands
public byte[] objectEncoding(byte[] key)
objectEncoding
in interface ControlBinaryCommands
objectEncoding
in interface KeyBinaryCommands
public Long objectIdletime(byte[] key)
objectIdletime
in interface ControlBinaryCommands
objectIdletime
in interface KeyBinaryCommands
public List<byte[]> objectHelpBinary()
objectHelpBinary
in interface ControlBinaryCommands
public Long objectFreq(byte[] key)
objectFreq
in interface ControlBinaryCommands
objectFreq
in interface KeyBinaryCommands
public long bitcount(byte[] key)
bitcount
in interface StringBinaryCommands
public long bitcount(byte[] key, long start, long end)
bitcount
in interface StringBinaryCommands
public long bitop(BitOP op, byte[] destKey, byte[]... srcKeys)
bitop
in interface StringBinaryCommands
public byte[] dump(byte[] key)
dump
in interface KeyBinaryCommands
public String restore(byte[] key, long ttl, byte[] serializedValue)
restore
in interface KeyBinaryCommands
public String restore(byte[] key, long ttl, byte[] serializedValue, RestoreParams params)
restore
in interface KeyBinaryCommands
public long pexpire(byte[] key, long milliseconds)
Volatile keys are stored on disk like the other keys, the timeout is persistent too like all the other aspects of the dataset. Saving a dataset containing expires and stopping the server does not stop the flow of time as Redis stores on disk the time when the key will no longer be available as Unix time, and not the remaining milliseconds.
Since Redis 2.1.3 you can update the value of the timeout of a key already having an expire
set. It is also possible to undo the expire at all turning the key into a normal key using the
PERSIST
command.
Time complexity: O(1)
pexpire
in interface KeyBinaryCommands
key
- milliseconds
- public long pexpireAt(byte[] key, long millisecondsTimestamp)
pexpireAt
in interface KeyBinaryCommands
public long pttl(byte[] key)
pttl
in interface KeyBinaryCommands
public String psetex(byte[] key, long milliseconds, byte[] value)
#setex(byte[], int, byte[])
with the sole difference that the
expire time is specified in milliseconds instead of seconds. Time complexity: O(1)psetex
in interface StringBinaryCommands
key
- milliseconds
- value
- public byte[] memoryDoctorBinary()
memoryDoctorBinary
in interface ControlBinaryCommands
public Long memoryUsage(byte[] key)
memoryUsage
in interface ControlBinaryCommands
memoryUsage
in interface KeyBinaryCommands
public Long memoryUsage(byte[] key, int samples)
memoryUsage
in interface ControlBinaryCommands
memoryUsage
in interface KeyBinaryCommands
public String failover()
failover
in interface GenericControlCommands
public String failover(FailoverParams failoverParams)
failover
in interface GenericControlCommands
public String failoverAbort()
failoverAbort
in interface GenericControlCommands
public byte[] aclWhoAmIBinary()
AccessControlLogBinaryCommands
aclWhoAmIBinary
in interface AccessControlLogBinaryCommands
public byte[] aclGenPassBinary()
AccessControlLogBinaryCommands
aclGenPassBinary
in interface AccessControlLogBinaryCommands
public byte[] aclGenPassBinary(int bits)
AccessControlLogBinaryCommands
aclGenPassBinary
in interface AccessControlLogBinaryCommands
bits
- the number of output bitspublic List<byte[]> aclListBinary()
AccessControlLogBinaryCommands
aclListBinary
in interface AccessControlLogBinaryCommands
public List<byte[]> aclUsersBinary()
AccessControlLogBinaryCommands
aclUsersBinary
in interface AccessControlLogBinaryCommands
public AccessControlUser aclGetUser(byte[] name)
aclGetUser
in interface AccessControlLogBinaryCommands
public String aclSetUser(byte[] name)
AccessControlLogBinaryCommands
aclSetUser
in interface AccessControlLogBinaryCommands
name
- user who receives an aclpublic String aclSetUser(byte[] name, byte[]... keys)
AccessControlLogBinaryCommands
aclSetUser
in interface AccessControlLogBinaryCommands
name
- user who receives an aclkeys
- the acl rules for the specified userpublic long aclDelUser(byte[] name)
AccessControlLogBinaryCommands
aclDelUser
in interface AccessControlLogBinaryCommands
name
- The username to deletepublic long aclDelUser(byte[] name, byte[]... names)
AccessControlLogBinaryCommands
aclDelUser
in interface AccessControlLogBinaryCommands
name
- The username to deletenames
- Other usernames to deletepublic List<byte[]> aclCatBinary()
AccessControlLogBinaryCommands
aclCatBinary
in interface AccessControlLogBinaryCommands
public List<byte[]> aclCat(byte[] category)
AccessControlLogBinaryCommands
aclCat
in interface AccessControlLogBinaryCommands
category
- The category for which to list available ACLspublic List<byte[]> aclLogBinary()
AccessControlLogBinaryCommands
aclLogBinary
in interface AccessControlLogBinaryCommands
public List<byte[]> aclLogBinary(int limit)
AccessControlLogBinaryCommands
aclLogBinary
in interface AccessControlLogBinaryCommands
limit
- The number of results to returnpublic String aclLogReset()
AccessControlLogCommands
aclLogReset
in interface AccessControlLogBinaryCommands
aclLogReset
in interface AccessControlLogCommands
public String clientKill(byte[] ipPort)
clientKill
in interface ClientBinaryCommands
public String clientKill(String ip, int port)
clientKill
in interface ClientBinaryCommands
clientKill
in interface ClientCommands
public long clientKill(ClientKillParams params)
clientKill
in interface ClientBinaryCommands
clientKill
in interface ClientCommands
public byte[] clientGetnameBinary()
clientGetnameBinary
in interface ClientBinaryCommands
public byte[] clientListBinary()
clientListBinary
in interface ClientBinaryCommands
public byte[] clientListBinary(ClientType type)
clientListBinary
in interface ClientBinaryCommands
public byte[] clientListBinary(long... clientIds)
clientListBinary
in interface ClientBinaryCommands
public byte[] clientInfoBinary()
clientInfoBinary
in interface ClientBinaryCommands
public String clientSetname(byte[] name)
clientSetname
in interface ClientBinaryCommands
public long clientId()
clientId
in interface ClientBinaryCommands
clientId
in interface ClientCommands
public long clientUnblock(long clientId)
clientUnblock
in interface ClientBinaryCommands
clientUnblock
in interface ClientCommands
clientId
- public long clientUnblock(long clientId, UnblockType unblockType)
clientUnblock
in interface ClientBinaryCommands
clientUnblock
in interface ClientCommands
clientId
- unblockType
- public String clientPause(long timeout)
clientPause
in interface ClientBinaryCommands
clientPause
in interface ClientCommands
public String clientPause(long timeout, ClientPauseMode mode)
clientPause
in interface ClientBinaryCommands
clientPause
in interface ClientCommands
public String migrate(String host, int port, byte[] key, int destinationDb, int timeout)
migrate
in interface DatabaseCommands
public String migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, byte[]... keys)
migrate
in interface DatabaseCommands
public String migrate(String host, int port, byte[] key, int timeout)
migrate
in interface KeyBinaryCommands
public String migrate(String host, int port, int timeout, MigrateParams params, byte[]... keys)
migrate
in interface KeyBinaryCommands
public long waitReplicas(int replicas, long timeout)
ServerCommands
Blocks until all the previous write commands are successfully transferred and acknowledged by at least the specified number of replicas. If the timeout, specified in milliseconds, is reached, the command returns even if the specified number of replicas were not yet reached.
Since Java Object class has implemented wait
method, we cannot use it.
waitReplicas
in interface ServerCommands
replicas
- successfully transferred and acknowledged by at least the specified number of
replicastimeout
- the time to block in milliseconds, a timeout of 0 means to block foreverpublic long pfadd(byte[] key, byte[]... elements)
pfadd
in interface HyperLogLogBinaryCommands
public long pfcount(byte[] key)
pfcount
in interface HyperLogLogBinaryCommands
public String pfmerge(byte[] destkey, byte[]... sourcekeys)
pfmerge
in interface HyperLogLogBinaryCommands
public long pfcount(byte[]... keys)
pfcount
in interface HyperLogLogBinaryCommands
public ScanResult<byte[]> scan(byte[] cursor)
scan
in interface KeyBinaryCommands
public ScanResult<byte[]> scan(byte[] cursor, ScanParams params)
scan
in interface KeyBinaryCommands
public ScanResult<byte[]> scan(byte[] cursor, ScanParams params, byte[] type)
scan
in interface KeyBinaryCommands
public ScanResult<Map.Entry<byte[],byte[]>> hscan(byte[] key, byte[] cursor)
hscan
in interface HashBinaryCommands
public ScanResult<Map.Entry<byte[],byte[]>> hscan(byte[] key, byte[] cursor, ScanParams params)
hscan
in interface HashBinaryCommands
public ScanResult<byte[]> sscan(byte[] key, byte[] cursor)
sscan
in interface SetBinaryCommands
public ScanResult<byte[]> sscan(byte[] key, byte[] cursor, ScanParams params)
sscan
in interface SetBinaryCommands
public ScanResult<Tuple> zscan(byte[] key, byte[] cursor)
zscan
in interface SortedSetBinaryCommands
public ScanResult<Tuple> zscan(byte[] key, byte[] cursor, ScanParams params)
zscan
in interface SortedSetBinaryCommands
public long geoadd(byte[] key, double longitude, double latitude, byte[] member)
geoadd
in interface GeoBinaryCommands
public long geoadd(byte[] key, Map<byte[],GeoCoordinate> memberCoordinateMap)
geoadd
in interface GeoBinaryCommands
public long geoadd(byte[] key, GeoAddParams params, Map<byte[],GeoCoordinate> memberCoordinateMap)
geoadd
in interface GeoBinaryCommands
public Double geodist(byte[] key, byte[] member1, byte[] member2)
geodist
in interface GeoBinaryCommands
public Double geodist(byte[] key, byte[] member1, byte[] member2, GeoUnit unit)
geodist
in interface GeoBinaryCommands
public List<byte[]> geohash(byte[] key, byte[]... members)
geohash
in interface GeoBinaryCommands
public List<GeoCoordinate> geopos(byte[] key, byte[]... members)
geopos
in interface GeoBinaryCommands
public List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude, double radius, GeoUnit unit)
georadius
in interface GeoBinaryCommands
public List<GeoRadiusResponse> georadiusReadonly(byte[] key, double longitude, double latitude, double radius, GeoUnit unit)
georadiusReadonly
in interface GeoBinaryCommands
public List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param)
georadius
in interface GeoBinaryCommands
public long georadiusStore(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam)
georadiusStore
in interface GeoBinaryCommands
public List<GeoRadiusResponse> georadiusReadonly(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param)
georadiusReadonly
in interface GeoBinaryCommands
public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit)
georadiusByMember
in interface GeoBinaryCommands
public List<GeoRadiusResponse> georadiusByMemberReadonly(byte[] key, byte[] member, double radius, GeoUnit unit)
georadiusByMemberReadonly
in interface GeoBinaryCommands
public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param)
georadiusByMember
in interface GeoBinaryCommands
public long georadiusByMemberStore(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam)
georadiusByMemberStore
in interface GeoBinaryCommands
public List<GeoRadiusResponse> georadiusByMemberReadonly(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param)
georadiusByMemberReadonly
in interface GeoBinaryCommands
public List<Long> bitfield(byte[] key, byte[]... arguments)
bitfield
in interface StringBinaryCommands
public List<Long> bitfieldReadonly(byte[] key, byte[]... arguments)
bitfieldReadonly
in interface StringBinaryCommands
public long hstrlen(byte[] key, byte[] field)
hstrlen
in interface HashBinaryCommands
public List<byte[]> xread(XReadParams xReadParams, Map.Entry<byte[],byte[]>... streams)
xread
in interface StreamBinaryCommands
public List<byte[]> xreadGroup(byte[] groupname, byte[] consumer, XReadGroupParams xReadGroupParams, Map.Entry<byte[],byte[]>... streams)
xreadGroup
in interface StreamBinaryCommands
public byte[] xadd(byte[] key, XAddParams params, Map<byte[],byte[]> hash)
xadd
in interface StreamBinaryCommands
public long xlen(byte[] key)
xlen
in interface StreamBinaryCommands
public List<byte[]> xrange(byte[] key, byte[] start, byte[] end)
xrange
in interface StreamBinaryCommands
public List<byte[]> xrange(byte[] key, byte[] start, byte[] end, int count)
xrange
in interface StreamBinaryCommands
public List<byte[]> xrevrange(byte[] key, byte[] end, byte[] start)
xrevrange
in interface StreamBinaryCommands
public List<byte[]> xrevrange(byte[] key, byte[] end, byte[] start, int count)
xrevrange
in interface StreamBinaryCommands
public long xack(byte[] key, byte[] group, byte[]... ids)
xack
in interface StreamBinaryCommands
public String xgroupCreate(byte[] key, byte[] consumer, byte[] id, boolean makeStream)
xgroupCreate
in interface StreamBinaryCommands
public String xgroupSetID(byte[] key, byte[] consumer, byte[] id)
xgroupSetID
in interface StreamBinaryCommands
public long xgroupDestroy(byte[] key, byte[] consumer)
xgroupDestroy
in interface StreamBinaryCommands
public long xgroupDelConsumer(byte[] key, byte[] consumer, byte[] consumerName)
xgroupDelConsumer
in interface StreamBinaryCommands
public long xdel(byte[] key, byte[]... ids)
xdel
in interface StreamBinaryCommands
public long xtrim(byte[] key, long maxLen, boolean approximateLength)
xtrim
in interface StreamBinaryCommands
public long xtrim(byte[] key, XTrimParams params)
xtrim
in interface StreamBinaryCommands
public List<Object> xpending(byte[] key, byte[] groupname, byte[] start, byte[] end, int count, byte[] consumername)
xpending
in interface StreamBinaryCommands
public Object xpending(byte[] key, byte[] groupname)
xpending
in interface StreamBinaryCommands
public List<Object> xpending(byte[] key, byte[] groupname, XPendingParams params)
xpending
in interface StreamBinaryCommands
public List<byte[]> xclaim(byte[] key, byte[] group, byte[] consumername, long minIdleTime, XClaimParams params, byte[]... ids)
xclaim
in interface StreamBinaryCommands
public List<byte[]> xclaimJustId(byte[] key, byte[] group, byte[] consumername, long minIdleTime, XClaimParams params, byte[]... ids)
xclaimJustId
in interface StreamBinaryCommands
public List<Object> xautoclaim(byte[] key, byte[] groupName, byte[] consumerName, long minIdleTime, byte[] start, XAutoClaimParams params)
xautoclaim
in interface StreamBinaryCommands
public List<Object> xautoclaimJustId(byte[] key, byte[] groupName, byte[] consumerName, long minIdleTime, byte[] start, XAutoClaimParams params)
xautoclaimJustId
in interface StreamBinaryCommands
public Object xinfoStream(byte[] key)
xinfoStream
in interface StreamBinaryCommands
public List<Object> xinfoGroup(byte[] key)
xinfoGroup
in interface StreamBinaryCommands
public List<Object> xinfoConsumers(byte[] key, byte[] group)
xinfoConsumers
in interface StreamBinaryCommands
public Object sendCommand(ProtocolCommand cmd, byte[]... args)
public Object sendBlockingCommand(ProtocolCommand cmd, byte[]... args)
public Object sendCommand(ProtocolCommand cmd)
public boolean copy(String srcKey, String dstKey, int db, boolean replace)
copy
in interface DatabaseCommands
srcKey
- the source key.dstKey
- the destination key.db
- replace
- public boolean copy(String srcKey, String dstKey, boolean replace)
copy
in interface KeyCommands
srcKey
- the source key.dstKey
- the destination key.replace
- public String ping(String message)
ping
in interface ServerCommands
message
- public String set(String key, String value)
Time complexity: O(1)
set
in interface StringCommands
key
- value
- public String set(String key, String value, SetParams params)
set
in interface StringCommands
key
- value
- params
- NX|XX, NX -- Only set the key if it does not already exist. XX -- Only set the
key if it already exist. EX|PX, expire time units: EX = seconds; PX = millisecondspublic String get(String key)
Time complexity: O(1)
get
in interface StringCommands
key
- public String getDel(String key)
Time complexity: O(1)
getDel
in interface StringCommands
key
- public String getEx(String key, GetExParams params)
getEx
in interface StringCommands
public long exists(String... keys)
exists
in interface KeyCommands
keys
- public boolean exists(String key)
exists
in interface KeyCommands
key
- public long del(String... keys)
del
in interface KeyCommands
keys
- public long del(String key)
del
in interface KeyCommands
public long unlink(String... keys)
Time complexity: O(1) for each key removed regardless of its size. Then the command does O(N) work in a different thread in order to reclaim memory, where N is the number of allocations the deleted objects where composed of.
unlink
in interface KeyCommands
keys
- public long unlink(String key)
unlink
in interface KeyCommands
public String type(String key)
type
in interface KeyCommands
key
- public Set<String> keys(String pattern)
keys
in interface KeyCommands
public String randomKey()
Time complexity: O(1)
randomKey
in interface KeyCommands
public String rename(String oldkey, String newkey)
Time complexity: O(1)
rename
in interface KeyCommands
oldkey
- newkey
- public long renamenx(String oldkey, String newkey)
Time complexity: O(1)
renamenx
in interface KeyCommands
oldkey
- newkey
- public long expire(String key, long seconds)
Volatile keys are stored on disk like the other keys, the timeout is persistent too like all the other aspects of the dataset. Saving a dataset containing expires and stopping the server does not stop the flow of time as Redis stores on disk the time when the key will no longer be available as Unix time, and not the remaining seconds.
Since Redis 2.1.3 you can update the value of the timeout of a key already having an expire
set. It is also possible to undo the expire at all turning the key into a normal key using the
PERSIST
command.
Time complexity: O(1)
expire
in interface KeyCommands
key
- seconds
- public long expireAt(String key, long unixTime)
EXPIRE
but instead to get the number
of seconds representing the Time To Live of the key as a second argument (that is a relative
way of specifying the TTL), it takes an absolute one in the form of a UNIX timestamp (Number of
seconds elapsed since 1 Gen 1970).
EXPIREAT was introduced in order to implement the Append Only File persistence mode so that EXPIRE commands are automatically translated into EXPIREAT commands for the append only file. Of course EXPIREAT can also used by programmers that need a way to simply specify that a given key should expire at a given time in the future.
Since Redis 2.1.3 you can update the value of the timeout of a key already having an expire
set. It is also possible to undo the expire at all turning the key into a normal key using the
PERSIST
command.
Time complexity: O(1)
expireAt
in interface KeyCommands
key
- unixTime
- public long ttl(String key)
EXPIRE
set. This introspection capability allows a Redis connection to
check how many seconds a given key will continue to be part of the dataset.ttl
in interface KeyCommands
key
- public long touch(String... keys)
touch
in interface KeyCommands
keys
- public long touch(String key)
touch
in interface KeyCommands
public long move(String key, int dbIndex)
move
in interface DatabaseCommands
key
- dbIndex
- public String getSet(String key, String value)
Time complexity: O(1)
getSet
in interface StringCommands
key
- value
- public List<String> mget(String... keys)
Time complexity: O(1) for every key
mget
in interface StringCommands
keys
- public long setnx(String key, String value)
SET
with the only difference that if the
key already exists no operation is performed. SETNX actually means "SET if Not eXists".
Time complexity: O(1)
setnx
in interface StringCommands
key
- value
- public String setex(String key, long seconds, String value)
SET
+ EXPIRE
. The operation is
atomic.
Time complexity: O(1)
setex
in interface StringCommands
key
- seconds
- value
- public String mset(String... keysvalues)
MSETNX
will not perform any operation at all even if
just a single key already exists.
Because of this semantic MSETNX can be used in order to set different keys representing different fields of an unique logic object in a way that ensures that either all the fields or none at all are set.
Both MSET and MSETNX are atomic operations. This means that for instance if the keys A and B are modified, another connection talking to Redis can either see the changes to both A and B at once, or no modification at all.
mset
in interface StringCommands
keysvalues
- msetnx(String...)
public long msetnx(String... keysvalues)
MSET
will
replace old values with new values, while MSETNX will not perform any operation at all even if
just a single key already exists.
Because of this semantic MSETNX can be used in order to set different keys representing different fields of an unique logic object in a way that ensures that either all the fields or none at all are set.
Both MSET and MSETNX are atomic operations. This means that for instance if the keys A and B are modified, another connection talking to Redis can either see the changes to both A and B at once, or no modification at all.
msetnx
in interface StringCommands
keysvalues
- mset(String...)
public long decrBy(String key, long decrement)
INCR
but instead to decrement by 1 the decrement
is integer.
INCR commands are limited to 64 bit signed integers.
Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.
Time complexity: O(1)
decrBy
in interface StringCommands
key
- decrement
- incr(String)
,
decr(String)
,
incrBy(String, long)
public long decr(String key)
INCR commands are limited to 64 bit signed integers.
Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.
Time complexity: O(1)
decr
in interface StringCommands
key
- incr(String)
,
incrBy(String, long)
,
decrBy(String, long)
public long incrBy(String key, long increment)
INCR
but instead to increment by 1 the increment is
integer.
INCR commands are limited to 64 bit signed integers.
Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.
Time complexity: O(1)
incrBy
in interface StringCommands
key
- increment
- incr(String)
,
decr(String)
,
decrBy(String, long)
public double incrByFloat(String key, double increment)
INCRBYFLOAT commands are limited to double precision floating point values.
Note: this is actually a string operation, that is, in Redis there are not "double" types. Simply the string stored at the key is parsed as a base double precision floating point value, incremented, and then converted back as a string. There is no DECRYBYFLOAT but providing a negative value will work as expected.
Time complexity: O(1)
incrByFloat
in interface StringCommands
key
- increment
- public long incr(String key)
INCR commands are limited to 64 bit signed integers.
Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.
Time complexity: O(1)
incr
in interface StringCommands
key
- incrBy(String, long)
,
decr(String)
,
decrBy(String, long)
public long append(String key, String value)
Time complexity: O(1). The amortized time complexity is O(1) assuming the appended value is small and the already present value is of any size, since the dynamic string library used by Redis will double the free space available on every reallocation.
append
in interface StringCommands
key
- value
- public String substr(String key, int start, int end)
The function handles out of range requests without raising an error, but just limiting the resulting range to the actual length of the string.
Time complexity: O(start+n) (with start being the start index and n the total length of the requested range). Note that the lookup part of this command is O(1) so for small strings this is actually an O(1) command.
substr
in interface StringCommands
key
- start
- end
- public long hset(String key, String field, String value)
If key does not exist, a new key holding a hash is created.
Time complexity: O(1)
hset
in interface HashCommands
key
- field
- value
- public long hset(String key, Map<String,String> hash)
hset
in interface HashCommands
public String hget(String key, String field)
If the field is not found or the key does not exist, a special 'nil' value is returned.
Time complexity: O(1)
hget
in interface HashCommands
key
- field
- public long hsetnx(String key, String field, String value)
hsetnx
in interface HashCommands
key
- field
- value
- public String hmset(String key, Map<String,String> hash)
If key does not exist, a new key holding a hash is created.
Time complexity: O(N) (with N being the number of fields)
hmset
in interface HashCommands
key
- hash
- public List<String> hmget(String key, String... fields)
If some of the specified fields do not exist, nil values are returned. Non existing keys are considered like empty hashes.
Time complexity: O(N) (with N being the number of fields)
hmget
in interface HashCommands
key
- fields
- public long hincrBy(String key, String field, long value)
The range of values supported by HINCRBY is limited to 64 bit signed integers.
Time complexity: O(1)
hincrBy
in interface HashCommands
key
- field
- value
- public double hincrByFloat(String key, String field, double value)
The range of values supported by HINCRBYFLOAT is limited to double precision floating point values.
Time complexity: O(1)
hincrByFloat
in interface HashCommands
key
- field
- value
- public boolean hexists(String key, String field)
hexists
in interface HashCommands
key
- field
- public long hdel(String key, String... fields)
Time complexity: O(1)
hdel
in interface HashCommands
key
- fields
- public long hlen(String key)
Time complexity: O(1)
hlen
in interface HashCommands
key
- public Set<String> hkeys(String key)
Time complexity: O(N), where N is the total number of entries
hkeys
in interface HashCommands
key
- public List<String> hvals(String key)
Time complexity: O(N), where N is the total number of entries
hvals
in interface HashCommands
key
- public Map<String,String> hgetAll(String key)
Time complexity: O(N), where N is the total number of entries
hgetAll
in interface HashCommands
key
- public String hrandfield(String key)
Time complexity: O(N), where N is the number of fields returned
hrandfield
in interface HashCommands
key
- public List<String> hrandfield(String key, long count)
Time complexity: O(N), where N is the number of fields returned
hrandfield
in interface HashCommands
key
- count
- public Map<String,String> hrandfieldWithValues(String key, long count)
Time complexity: O(N), where N is the number of fields returned
hrandfieldWithValues
in interface HashCommands
key
- count
- public long rpush(String key, String... strings)
Time complexity: O(1)
rpush
in interface ListCommands
key
- strings
- public long lpush(String key, String... strings)
Time complexity: O(1)
lpush
in interface ListCommands
key
- strings
- public long llen(String key)
Time complexity: O(1)
llen
in interface ListCommands
key
- public List<String> lrange(String key, long start, long stop)
For example LRANGE foobar 0 2 will return the first three elements of the list.
start and end can also be negative numbers indicating offsets from the end of the list. For example -1 is the last element of the list, -2 the penultimate element and so on.
Consistency with range functions in various programming languages
Note that if you have a list of numbers from 0 to 100, LRANGE 0 10 will return 11 elements, that is, rightmost item is included. This may or may not be consistent with behavior of range-related functions in your programming language of choice (think Ruby's Range.new, Array#slice or Python's range() function).
LRANGE behavior is consistent with one of Tcl.
Out-of-range indexes
Indexes out of range will not produce an error: if start is over the end of the list, or start > end, an empty list is returned. If end is over the end of the list Redis will threat it just like the last element of the list.
Time complexity: O(start+n) (with n being the length of the range and start being the start offset)
lrange
in interface ListCommands
key
- start
- stop
- public String ltrim(String key, long start, long stop)
For example LTRIM foobar 0 2 will modify the list stored at foobar key so that only the first three elements of the list will remain.
start and end can also be negative numbers indicating offsets from the end of the list. For example -1 is the last element of the list, -2 the penultimate element and so on.
Indexes out of range will not produce an error: if start is over the end of the list, or start > end, an empty list is left as value. If end over the end of the list Redis will threat it just like the last element of the list.
Hint: the obvious use of LTRIM is together with LPUSH/RPUSH. For example:
lpush("mylist", "someelement"); ltrim("mylist", 0, 99); *
The above two commands will push elements in the list taking care that the list will not grow without limits. This is very useful when using Redis to store logs for example. It is important to note that when used in this way LTRIM is an O(1) operation because in the average case just one element is removed from the tail of the list.
Time complexity: O(n) (with n being len of list - len of range)
ltrim
in interface ListCommands
key
- start
- stop
- public String lindex(String key, long index)
If the value stored at key is not of list type an error is returned. If the index is out of range a 'nil' reply is returned.
Note that even if the average time complexity is O(n) asking for the first or the last element of the list is O(1).
Time complexity: O(n) (with n being the length of the list)
lindex
in interface ListCommands
key
- index
- public String lset(String key, long index, String value)
Out of range indexes will generate an error.
Similarly to other list commands accepting indexes, the index can be negative to access elements starting from the end of the list. So -1 is the last element, -2 is the penultimate, and so forth.
Time complexity:
O(N) (with N being the length of the list), setting the first or last elements of the list is O(1).
lset
in interface ListCommands
key
- index
- value
- lindex(String, long)
public long lrem(String key, long count, String value)
Time complexity: O(N) (with N being the length of the list)
lrem
in interface ListCommands
key
- count
- value
- public String lpop(String key)
If the key does not exist or the list is already empty the special value 'nil' is returned.
lpop
in interface ListCommands
key
- rpop(String)
public List<String> lpop(String key, int count)
lpop
in interface ListCommands
public Long lpos(String key, String element)
lpos
in interface ListCommands
public Long lpos(String key, String element, LPosParams params)
lpos
in interface ListCommands
public List<Long> lpos(String key, String element, LPosParams params, long count)
lpos
in interface ListCommands
public String rpop(String key)
If the key does not exist or the list is already empty the special value 'nil' is returned.
rpop
in interface ListCommands
key
- lpop(String)
public List<String> rpop(String key, int count)
rpop
in interface ListCommands
public String rpoplpush(String srckey, String dstkey)
If the key does not exist or the list is already empty the special value 'nil' is returned. If the srckey and dstkey are the same the operation is equivalent to removing the last element from the list and pushing it as first element of the list, so it's a "list rotation" command.
Time complexity: O(1)
rpoplpush
in interface ListCommands
srckey
- dstkey
- public long sadd(String key, String... members)
Time complexity O(1)
sadd
in interface SetCommands
key
- members
- public Set<String> smembers(String key)
SINTER
.
Time complexity O(N)
smembers
in interface SetCommands
key
- public long srem(String key, String... members)
Time complexity O(1)
srem
in interface SetCommands
key
- members
- public String spop(String key)
The srandmember(String)
command does a similar work but the returned element is not
removed from the Set.
Time complexity O(1)
spop
in interface SetCommands
key
- public Set<String> spop(String key, long count)
spop
in interface SetCommands
public long smove(String srckey, String dstkey, String 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.
Time complexity O(1)
smove
in interface SetCommands
srckey
- dstkey
- member
- public long scard(String key)
scard
in interface SetCommands
key
- public boolean sismember(String key, String member)
Time complexity O(1)
sismember
in interface SetCommands
key
- member
- public List<Boolean> smismember(String key, String... members)
Time complexity O(N) where N is the number of elements being checked for membership
smismember
in interface SetCommands
key
- members
- public Set<String> sinter(String... keys)
LRANGE
the result is sent to the
connection 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).
Time complexity O(N*M) worst case where N is the cardinality of the smallest set and M the number of sets
sinter
in interface SetCommands
keys
- public long sinterstore(String dstkey, String... keys)
SINTER
but instead of being returned
the resulting set is stored as dstkey.
Time complexity O(N*M) worst case where N is the cardinality of the smallest set and M the number of sets
sinterstore
in interface SetCommands
dstkey
- keys
- public Set<String> sunion(String... keys)
LRANGE
the result is sent to the connection 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.
Time complexity O(N) where N is the total number of elements in all the provided sets
sunion
in interface SetCommands
keys
- public long sunionstore(String dstkey, String... keys)
SUNION
but instead of being returned
the resulting set is stored as dstkey. Any existing value in dstkey will be over-written.
Time complexity O(N) where N is the total number of elements in all the provided sets
sunionstore
in interface SetCommands
dstkey
- keys
- public Set<String> sdiff(String... 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:
O(N) with N being the total number of elements of all the sets
sdiff
in interface SetCommands
keys
- public long sdiffstore(String dstkey, String... keys)
SDIFF
but instead of being returned
the resulting set is stored in dstkey.sdiffstore
in interface SetCommands
dstkey
- keys
- public String srandmember(String key)
The SPOP command does a similar work but the returned element is popped (removed) from the Set.
Time complexity O(1)
srandmember
in interface SetCommands
key
- public List<String> srandmember(String key, int count)
The SPOP command does a similar work but the returned elements is popped (removed) from the Set.
Time complexity O(1)
srandmember
in interface SetCommands
key
- count
- if positive, return an array of distinct elements.
If negative the behavior changes and the command is allowed to
return the same element multiple timespublic long zadd(String key, double score, String member)
The score value can be the string representation of a double precision floating point number.
Time complexity O(log(N)) with N being the number of elements in the sorted set
zadd
in interface SortedSetCommands
key
- score
- member
- public long zadd(String key, double score, String member, ZAddParams params)
zadd
in interface SortedSetCommands
public long zadd(String key, Map<String,Double> scoreMembers)
zadd
in interface SortedSetCommands
public long zadd(String key, Map<String,Double> scoreMembers, ZAddParams params)
zadd
in interface SortedSetCommands
public Double zaddIncr(String key, double score, String member, ZAddParams params)
zaddIncr
in interface SortedSetCommands
public Set<String> zdiff(String... keys)
zdiff
in interface SortedSetCommands
public Set<Tuple> zdiffWithScores(String... keys)
zdiffWithScores
in interface SortedSetCommands
public long zdiffStore(String dstkey, String... keys)
zdiffStore
in interface SortedSetCommands
public List<String> zrange(String key, long start, long stop)
zrange
in interface SortedSetCommands
public long zrem(String key, String... members)
Time complexity O(log(N)) with N being the number of elements in the sorted set
zrem
in interface SortedSetCommands
key
- members
- public double zincrby(String key, double increment, String member)
The score value can be the string representation of a double precision floating point number. It's possible to provide a negative value to perform a decrement.
For an introduction to sorted sets check the Introduction to Redis data types page.
Time complexity O(log(N)) with N being the number of elements in the sorted set
zincrby
in interface SortedSetCommands
key
- increment
- member
- public Double zincrby(String key, double increment, String member, ZIncrByParams params)
zincrby
in interface SortedSetCommands
public Long zrank(String key, String member)
When the given member does not exist in the sorted set, the special value 'nil' is returned. The returned rank (or index) of the member is 0-based for both commands.
Time complexity:
O(log(N))
zrank
in interface SortedSetCommands
key
- member
- zrevrank(String, String)
public Long zrevrank(String key, String member)
When the given member does not exist in the sorted set, the special value 'nil' is returned. The returned rank (or index) of the member is 0-based for both commands.
Time complexity:
O(log(N))
zrevrank
in interface SortedSetCommands
key
- member
- zrank(String, String)
public List<String> zrevrange(String key, long start, long stop)
zrevrange
in interface SortedSetCommands
public List<Tuple> zrangeWithScores(String key, long start, long stop)
zrangeWithScores
in interface SortedSetCommands
public List<Tuple> zrevrangeWithScores(String key, long start, long stop)
zrevrangeWithScores
in interface SortedSetCommands
public String zrandmember(String key)
zrandmember
in interface SortedSetCommands
public List<String> zrandmember(String key, long count)
zrandmember
in interface SortedSetCommands
public List<Tuple> zrandmemberWithScores(String key, long count)
zrandmemberWithScores
in interface SortedSetCommands
public long zcard(String key)
Time complexity O(1)
zcard
in interface SortedSetCommands
key
- public Double zscore(String key, String member)
Time complexity: O(1)
zscore
in interface SortedSetCommands
key
- member
- public List<Double> zmscore(String key, String... members)
Time complexity: O(N) where N is the number of members being requested.
zmscore
in interface SortedSetCommands
key
- members
- public Tuple zpopmax(String key)
zpopmax
in interface SortedSetCommands
public List<Tuple> zpopmax(String key, int count)
zpopmax
in interface SortedSetCommands
public Tuple zpopmin(String key)
zpopmin
in interface SortedSetCommands
public List<Tuple> zpopmin(String key, int count)
zpopmin
in interface SortedSetCommands
public List<String> sort(String key)
Sort the elements contained in the List, Set, or Sorted Set value at key. By default sorting is numeric with elements being compared as double precision floating point numbers. This is the simplest form of SORT.
sort
in interface KeyCommands
key
- sort(String, String)
,
sort(String, SortingParams)
,
sort(String, SortingParams, String)
public List<String> sort(String key, SortingParams sortingParameters)
examples:
Given are the following sets and key/values:
x = [1, 2, 3] y = [a, b, c] k1 = z k2 = y k3 = x w1 = 9 w2 = 8 w3 = 7Sort Order:
sort(x) or sort(x, sp.asc()) -> [1, 2, 3] sort(x, sp.desc()) -> [3, 2, 1] sort(y) -> [c, a, b] sort(y, sp.alpha()) -> [a, b, c] sort(y, sp.alpha().desc()) -> [c, a, b]Limit (e.g. for Pagination):
sort(x, sp.limit(0, 2)) -> [1, 2] sort(y, sp.alpha().desc().limit(1, 2)) -> [b, a]Sorting by external keys:
sort(x, sb.by(w*)) -> [3, 2, 1] sort(x, sb.by(w*).desc()) -> [1, 2, 3]Getting external keys:
sort(x, sp.by(w*).get(k*)) -> [x, y, z] sort(x, sp.by(w*).get(#).get(k*)) -> [3, x, 2, y, 1, z]
sort
in interface KeyCommands
key
- sortingParameters
- sort(String)
,
sort(String, SortingParams, String)
public long sort(String key, SortingParams sortingParameters, String dstkey)
sort
in interface KeyCommands
key
- sortingParameters
- dstkey
- sort(String, SortingParams)
,
sort(String)
,
sort(String, String)
public long sort(String key, String dstkey)
Sort the elements contained in the List, Set, or Sorted Set value at key and store the result at dstkey. By default sorting is numeric with elements being compared as double precision floating point numbers. This is the simplest form of SORT.
sort
in interface KeyCommands
key
- dstkey
- sort(String)
,
sort(String, SortingParams)
,
sort(String, SortingParams, String)
public String lmove(String srcKey, String dstKey, ListDirection from, ListDirection to)
lmove
in interface ListCommands
public String blmove(String srcKey, String dstKey, ListDirection from, ListDirection to, double timeout)
blmove
in interface ListCommands
public List<String> blpop(int timeout, String... keys)
The following is a description of the exact semantic. We describe BLPOP but the two commands are identical, the only difference is that BLPOP pops the element from the left (head) of the list, and BRPOP pops from the right (tail).
Non blocking behavior
When BLPOP is called, if at least one of the specified keys contain a non empty list, an element is popped from the head of the list and returned to the caller together with the name of the key (BLPOP returns a two elements array, the first element is the key, the second the popped value).
Keys are scanned from left to right, so for instance if you issue BLPOP list1 list2 list3 0 against a dataset where list1 does not exist but list2 and list3 contain non empty lists, BLPOP guarantees to return an element from the list stored at list2 (since it is the first non empty list starting from the left).
Blocking behavior
If none of the specified keys exist or contain non empty lists, BLPOP blocks until some other connection performs a LPUSH or an RPUSH operation against one of the lists.
Once new data is present on one of the lists, the connection finally returns with the name of the key unblocking it and the popped value.
When blocking, if a non-zero timeout is specified, the connection will unblock returning a nil special value if the specified amount of seconds passed without a push operation against at least one of the specified keys.
The timeout argument is interpreted as an integer value. A timeout of zero means instead to block forever.
Multiple clients blocking for the same keys
Multiple clients can block for the same key. They are put into a queue, so the first to be served will be the one that started to wait earlier, in a first-blpopping first-served fashion.
blocking POP inside a MULTI/EXEC transaction
BLPOP and BRPOP can be used with pipelining (sending multiple commands and reading the replies in batch), but it does not make sense to use BLPOP or BRPOP inside a MULTI/EXEC block (a Redis transaction).
The behavior of BLPOP inside MULTI/EXEC when the list is empty is to return a multi-bulk nil reply, exactly what happens when the timeout is reached. If you like science fiction, think at it like if inside MULTI/EXEC the time will flow at infinite speed :)
Time complexity: O(1)
blpop
in interface ListCommands
timeout
- keys
- When a non-zero timeout is specified, and the BLPOP operation timed out, the return value is a nil multi bulk reply. Most connection values will return false or nil accordingly to the programming language used.
brpop(int, String...)
public KeyedListElement blpop(double timeout, String... keys)
blpop
in interface ListCommands
public List<String> brpop(int timeout, String... keys)
The following is a description of the exact semantic. We describe BLPOP but the two commands are identical, the only difference is that BLPOP pops the element from the left (head) of the list, and BRPOP pops from the right (tail).
Non blocking behavior
When BLPOP is called, if at least one of the specified keys contain a non empty list, an element is popped from the head of the list and returned to the caller together with the name of the key (BLPOP returns a two elements array, the first element is the key, the second the popped value).
Keys are scanned from left to right, so for instance if you issue BLPOP list1 list2 list3 0 against a dataset where list1 does not exist but list2 and list3 contain non empty lists, BLPOP guarantees to return an element from the list stored at list2 (since it is the first non empty list starting from the left).
Blocking behavior
If none of the specified keys exist or contain non empty lists, BLPOP blocks until some other connection performs a LPUSH or an RPUSH operation against one of the lists.
Once new data is present on one of the lists, the connection finally returns with the name of the key unblocking it and the popped value.
When blocking, if a non-zero timeout is specified, the connection will unblock returning a nil special value if the specified amount of seconds passed without a push operation against at least one of the specified keys.
The timeout argument is interpreted as an integer value. A timeout of zero means instead to block forever.
Multiple clients blocking for the same keys
Multiple clients can block for the same key. They are put into a queue, so the first to be served will be the one that started to wait earlier, in a first-blpopping first-served fashion.
blocking POP inside a MULTI/EXEC transaction
BLPOP and BRPOP can be used with pipelining (sending multiple commands and reading the replies in batch), but it does not make sense to use BLPOP or BRPOP inside a MULTI/EXEC block (a Redis transaction).
The behavior of BLPOP inside MULTI/EXEC when the list is empty is to return a multi-bulk nil reply, exactly what happens when the timeout is reached. If you like science fiction, think at it like if inside MULTI/EXEC the time will flow at infinite speed :)
Time complexity: O(1)
brpop
in interface ListCommands
timeout
- keys
- When a non-zero timeout is specified, and the BLPOP operation timed out, the return value is a nil multi bulk reply. Most connection values will return false or nil accordingly to the programming language used.
blpop(int, String...)
public KeyedListElement brpop(double timeout, String... keys)
brpop
in interface ListCommands
public KeyedZSetElement bzpopmax(double timeout, String... keys)
bzpopmax
in interface SortedSetCommands
public KeyedZSetElement bzpopmin(double timeout, String... keys)
bzpopmin
in interface SortedSetCommands
public List<String> blpop(int timeout, String key)
blpop
in interface ListCommands
public KeyedListElement blpop(double timeout, String key)
blpop
in interface ListCommands
public List<String> brpop(int timeout, String key)
brpop
in interface ListCommands
public KeyedListElement brpop(double timeout, String key)
brpop
in interface ListCommands
public long zcount(String key, double min, double max)
zcount
in interface SortedSetCommands
public long zcount(String key, String min, String max)
zcount
in interface SortedSetCommands
public List<String> zrangeByScore(String key, double min, double max)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional LIMIT
it's possible
to get only a range of the matching elements in an SQL-alike way. Note that if offset is large
the commands needs to traverse the list for offset elements and this adds up to the O(M)
figure.
The ZCOUNT
command is similar to
ZRANGEBYSCORE
but instead of returning the
actual elements in the specified interval, it just returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
zrangeByScore
in interface SortedSetCommands
key
- min
- a double or Double.NEGATIVE_INFINITY for "-inf"max
- a double or Double.POSITIVE_INFINITY for "+inf"zrangeByScore(String, double, double)
,
zrangeByScore(String, double, double, int, int)
,
zrangeByScoreWithScores(String, double, double)
,
zrangeByScoreWithScores(String, String, String)
,
zrangeByScoreWithScores(String, double, double, int, int)
,
zcount(String, double, double)
public List<String> zrangeByScore(String key, String min, String max)
zrangeByScore
in interface SortedSetCommands
public List<String> zrangeByScore(String key, double min, double max, int offset, int count)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional LIMIT
it's possible
to get only a range of the matching elements in an SQL-alike way. Note that if offset is large
the commands needs to traverse the list for offset elements and this adds up to the O(M)
figure.
The ZCOUNT
command is similar to
ZRANGEBYSCORE
but instead of returning the
actual elements in the specified interval, it just returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
zrangeByScore
in interface SortedSetCommands
key
- min
- max
- offset
- count
- zrangeByScore(String, double, double)
,
zrangeByScore(String, double, double, int, int)
,
zrangeByScoreWithScores(String, double, double)
,
zrangeByScoreWithScores(String, double, double, int, int)
,
zcount(String, double, double)
public List<String> zrangeByScore(String key, String min, String max, int offset, int count)
zrangeByScore
in interface SortedSetCommands
public List<Tuple> zrangeByScoreWithScores(String key, double min, double max)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional LIMIT
it's possible
to get only a range of the matching elements in an SQL-alike way. Note that if offset is large
the commands needs to traverse the list for offset elements and this adds up to the O(M)
figure.
The ZCOUNT
command is similar to
ZRANGEBYSCORE
but instead of returning the
actual elements in the specified interval, it just returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
zrangeByScoreWithScores
in interface SortedSetCommands
key
- min
- max
- zrangeByScore(String, double, double)
,
zrangeByScore(String, double, double, int, int)
,
zrangeByScoreWithScores(String, double, double)
,
zrangeByScoreWithScores(String, double, double, int, int)
,
zcount(String, double, double)
public List<Tuple> zrangeByScoreWithScores(String key, String min, String max)
zrangeByScoreWithScores
in interface SortedSetCommands
public List<Tuple> zrangeByScoreWithScores(String key, double min, double max, int offset, int count)
The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).
Using the optional LIMIT
it's possible
to get only a range of the matching elements in an SQL-alike way. Note that if offset is large
the commands needs to traverse the list for offset elements and this adds up to the O(M)
figure.
The ZCOUNT
command is similar to
ZRANGEBYSCORE
but instead of returning the
actual elements in the specified interval, it just returns the number of matching elements.
Exclusive intervals and infinity
min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".
Also while the interval is for default closed (inclusive) it's possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5
Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10
Will return all the values with score > 5 and < 10 (5 and 10 excluded).
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))
zrangeByScoreWithScores
in interface SortedSetCommands
key
- min
- max
- offset
- count
- zrangeByScore(String, double, double)
,
zrangeByScore(String, double, double, int, int)
,
zrangeByScoreWithScores(String, double, double)
,
zrangeByScoreWithScores(String, double, double, int, int)
,
zcount(String, double, double)
public List<Tuple> zrangeByScoreWithScores(String key, String min, String max, int offset, int count)
zrangeByScoreWithScores
in interface SortedSetCommands
public List<String> zrevrangeByScore(String key, double max, double min)
zrevrangeByScore
in interface SortedSetCommands
public List<String> zrevrangeByScore(String key, String max, String min)
zrevrangeByScore
in interface SortedSetCommands
public List<String> zrevrangeByScore(String key, double max, double min, int offset, int count)
zrevrangeByScore
in interface SortedSetCommands
public List<Tuple> zrevrangeByScoreWithScores(String key, double max, double min)
zrevrangeByScoreWithScores
in interface SortedSetCommands
public List<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count)
zrevrangeByScoreWithScores
in interface SortedSetCommands
public List<Tuple> zrevrangeByScoreWithScores(String key, String max, String min, int offset, int count)
zrevrangeByScoreWithScores
in interface SortedSetCommands
public List<String> zrevrangeByScore(String key, String max, String min, int offset, int count)
zrevrangeByScore
in interface SortedSetCommands
public List<Tuple> zrevrangeByScoreWithScores(String key, String max, String min)
zrevrangeByScoreWithScores
in interface SortedSetCommands
public long zremrangeByRank(String key, long start, long stop)
Time complexity: O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements removed by the operation
zremrangeByRank
in interface SortedSetCommands
key
- start
- stop
- public long zremrangeByScore(String key, double min, double max)
Time complexity:
O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements removed by the operation
zremrangeByScore
in interface SortedSetCommands
key
- min
- max
- public long zremrangeByScore(String key, String min, String max)
zremrangeByScore
in interface SortedSetCommands
public Set<String> zunion(ZParams params, String... keys)
zunion
in interface SortedSetCommands
params
- keys
- public Set<Tuple> zunionWithScores(ZParams params, String... keys)
zunionWithScores
in interface SortedSetCommands
params
- keys
- public long zunionstore(String dstkey, String... sets)
As the terms imply, the ZINTERSTORE
command requires an
element to be present in each of the given inputs to be inserted in the result. The
ZUNIONSTORE
command inserts all elements across all
inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
zunionstore
in interface SortedSetCommands
dstkey
- sets
- zunionstore(String, String...)
,
zunionstore(String, ZParams, String...)
,
zinterstore(String, String...)
,
zinterstore(String, ZParams, String...)
public long zunionstore(String dstkey, ZParams params, String... sets)
As the terms imply, the ZINTERSTORE
command requires an
element to be present in each of the given inputs to be inserted in the result. The
ZUNIONSTORE
command inserts all elements across all
inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
zunionstore
in interface SortedSetCommands
dstkey
- sets
- params
- zunionstore(String, String...)
,
zunionstore(String, ZParams, String...)
,
zinterstore(String, String...)
,
zinterstore(String, ZParams, String...)
public Set<String> zinter(ZParams params, String... keys)
zinter
in interface SortedSetCommands
params
- keys
- public Set<Tuple> zinterWithScores(ZParams params, String... keys)
zinterWithScores
in interface SortedSetCommands
params
- keys
- public long zinterstore(String dstkey, String... sets)
As the terms imply, the ZINTERSTORE
command requires an
element to be present in each of the given inputs to be inserted in the result. The
ZUNIONSTORE
command inserts all elements across all
inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
zinterstore
in interface SortedSetCommands
dstkey
- sets
- zunionstore(String, String...)
,
zunionstore(String, ZParams, String...)
,
zinterstore(String, String...)
,
zinterstore(String, ZParams, String...)
public long zinterstore(String dstkey, ZParams params, String... sets)
As the terms imply, the ZINTERSTORE
command requires an
element to be present in each of the given inputs to be inserted in the result. The
ZUNIONSTORE
command inserts all elements across all
inputs.
Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.
With the AGGREGATE option, it's possible to specify how the results of the union or intersection are aggregated. This option defaults to SUM, where the score of an element is summed across the inputs where it exists. When this option is set to be either MIN or MAX, the resulting set will contain the minimum or maximum score of an element across the inputs where it exists.
Time complexity: O(N) + O(M log(M)) with N being the sum of the sizes of the input sorted sets, and M being the number of elements in the resulting sorted set
zinterstore
in interface SortedSetCommands
dstkey
- sets
- params
- zunionstore(String, String...)
,
zunionstore(String, ZParams, String...)
,
zinterstore(String, String...)
,
zinterstore(String, ZParams, String...)
public long zlexcount(String key, String min, String max)
zlexcount
in interface SortedSetCommands
public List<String> zrangeByLex(String key, String min, String max)
zrangeByLex
in interface SortedSetCommands
public List<String> zrangeByLex(String key, String min, String max, int offset, int count)
zrangeByLex
in interface SortedSetCommands
public List<String> zrevrangeByLex(String key, String max, String min)
zrevrangeByLex
in interface SortedSetCommands
public List<String> zrevrangeByLex(String key, String max, String min, int offset, int count)
zrevrangeByLex
in interface SortedSetCommands
public long zremrangeByLex(String key, String min, String max)
zremrangeByLex
in interface SortedSetCommands
public long strlen(String key)
strlen
in interface StringCommands
public LCSMatchResult strAlgoLCSKeys(String keyA, String keyB, StrAlgoLCSParams params)
strAlgoLCSKeys
in interface StringCommands
keyA
- keyAkeyB
- keyBparams
- the paramspublic LCSMatchResult strAlgoLCSStrings(String strA, String strB, StrAlgoLCSParams params)
strA
- strAstrB
- strBparams
- the paramspublic long lpushx(String key, String... string)
lpushx
in interface ListCommands
public long persist(String key)
expire
at turning the expire key into a normal key.
Time complexity: O(1)
persist
in interface KeyCommands
key
- public long rpushx(String key, String... string)
rpushx
in interface ListCommands
public String echo(String string)
echo
in interface ServerCommands
public long linsert(String key, ListPosition where, String pivot, String value)
linsert
in interface ListCommands
public String brpoplpush(String source, String destination, int timeout)
brpoplpush
in interface ListCommands
source
- destination
- timeout
- public boolean setbit(String key, long offset, boolean value)
setbit
in interface StringCommands
key
- offset
- value
- public boolean getbit(String key, long offset)
getbit
in interface StringCommands
key
- offset
- public long setrange(String key, long offset, String value)
setrange
in interface StringCommands
public String getrange(String key, long startOffset, long endOffset)
getrange
in interface StringCommands
public long bitpos(String key, boolean value)
bitpos
in interface StringCommands
public long bitpos(String key, boolean value, BitPosParams params)
bitpos
in interface StringCommands
public List<Object> role()
role
in interface ControlCommands
public List<String> configGet(String pattern)
CONFIG GET returns the current configuration parameters. This sub command only accepts a single argument, that is glob style pattern. All the configuration parameters matching this parameter are reported as a list of key-value pairs.
Example:
$ redis-cli config get '*' 1. "dbfilename" 2. "dump.rdb" 3. "requirepass" 4. (nil) 5. "masterauth" 6. (nil) 7. "maxmemory" 8. "0\n" 9. "appendfsync" 10. "everysec" 11. "save" 12. "3600 1 300 100 60 10000" $ redis-cli config get 'm*' 1. "masterauth" 2. (nil) 3. "maxmemory" 4. "0\n"
configGet
in interface ConfigCommands
pattern
- public String configSet(String parameter, String value)
The list of configuration parameters supported by CONFIG SET can be obtained issuing a
CONFIG GET *
command.
The configuration set using CONFIG SET is immediately loaded by the Redis server that will start acting as specified starting from the next command.
Parameters value format
The value of the configuration parameter is the same as the one of the same parameter in the Redis configuration file, with the following exceptions:
configSet
in interface ConfigCommands
parameter
- value
- public void subscribe(JedisPubSub jedisPubSub, String... channels)
public void psubscribe(JedisPubSub jedisPubSub, String... patterns)
public Long pubsubNumPat()
public Object eval(String script, int keyCount, String... params)
eval
in interface ScriptingKeyCommands
public Object eval(String script, List<String> keys, List<String> args)
eval
in interface ScriptingKeyCommands
public Object eval(String script)
eval
in interface ScriptingKeyCommands
public Object evalsha(String sha1)
evalsha
in interface ScriptingKeyCommands
public Object evalsha(String sha1, List<String> keys, List<String> args)
evalsha
in interface ScriptingKeyCommands
public Object evalsha(String sha1, int keyCount, String... params)
evalsha
in interface ScriptingKeyCommands
public Boolean scriptExists(String sha1)
scriptExists
in interface ScriptingControlCommands
public List<Boolean> scriptExists(String... sha1)
scriptExists
in interface ScriptingControlCommands
public String scriptLoad(String script)
scriptLoad
in interface ScriptingControlCommands
public List<Slowlog> slowlogGet()
slowlogGet
in interface SlowlogCommands
public List<Slowlog> slowlogGet(long entries)
slowlogGet
in interface SlowlogCommands
public Long objectRefcount(String key)
objectRefcount
in interface ControlCommands
objectRefcount
in interface KeyCommands
public String objectEncoding(String key)
objectEncoding
in interface ControlCommands
objectEncoding
in interface KeyCommands
public Long objectIdletime(String key)
objectIdletime
in interface ControlCommands
objectIdletime
in interface KeyCommands
public List<String> objectHelp()
objectHelp
in interface ControlCommands
public Long objectFreq(String key)
objectFreq
in interface ControlCommands
objectFreq
in interface KeyCommands
public long bitcount(String key)
bitcount
in interface StringCommands
public long bitcount(String key, long start, long end)
bitcount
in interface StringCommands
public long bitop(BitOP op, String destKey, String... srcKeys)
bitop
in interface StringCommands
public byte[] dump(String key)
dump
in interface KeyCommands
public String restore(String key, long ttl, byte[] serializedValue)
restore
in interface KeyCommands
public String restore(String key, long ttl, byte[] serializedValue, RestoreParams params)
restore
in interface KeyCommands
public long pexpire(String key, long milliseconds)
pexpire
in interface KeyCommands
public long pexpireAt(String key, long millisecondsTimestamp)
pexpireAt
in interface KeyCommands
public long pttl(String key)
pttl
in interface KeyCommands
public String psetex(String key, long milliseconds, String value)
#setex(String, int, String)
with the sole difference that the
expire time is specified in milliseconds instead of seconds. Time complexity: O(1)psetex
in interface StringCommands
key
- milliseconds
- value
- public String aclSetUser(String name)
AccessControlLogCommands
aclSetUser
in interface AccessControlLogCommands
name
- user who receives an aclpublic String aclSetUser(String name, String... params)
AccessControlLogCommands
aclSetUser
in interface AccessControlLogCommands
name
- user who receives an aclparams
- the acl rules for the specified userpublic long aclDelUser(String name)
AccessControlLogCommands
aclDelUser
in interface AccessControlLogCommands
name
- The username to deletepublic long aclDelUser(String name, String... names)
AccessControlLogCommands
aclDelUser
in interface AccessControlLogCommands
name
- The username to deletenames
- Other usernames to deletepublic AccessControlUser aclGetUser(String name)
aclGetUser
in interface AccessControlLogCommands
public List<String> aclUsers()
AccessControlLogCommands
aclUsers
in interface AccessControlLogCommands
public List<String> aclList()
AccessControlLogCommands
aclList
in interface AccessControlLogCommands
public String aclWhoAmI()
AccessControlLogCommands
aclWhoAmI
in interface AccessControlLogCommands
public List<String> aclCat()
AccessControlLogCommands
aclCat
in interface AccessControlLogCommands
public List<String> aclCat(String category)
AccessControlLogCommands
aclCat
in interface AccessControlLogCommands
category
- The category for which to list available ACLspublic List<AccessControlLogEntry> aclLog()
AccessControlLogCommands
aclLog
in interface AccessControlLogCommands
public List<AccessControlLogEntry> aclLog(int limit)
AccessControlLogCommands
aclLog
in interface AccessControlLogCommands
limit
- The number of results to returnpublic String aclLoad()
AccessControlLogCommands
aclLoad
in interface AccessControlLogBinaryCommands
aclLoad
in interface AccessControlLogCommands
public String aclSave()
AccessControlLogCommands
aclSave
in interface AccessControlLogBinaryCommands
aclSave
in interface AccessControlLogCommands
public String aclGenPass()
AccessControlLogCommands
aclGenPass
in interface AccessControlLogCommands
public String aclGenPass(int bits)
AccessControlLogCommands
aclGenPass
in interface AccessControlLogCommands
bits
- the number of output bitspublic String clientKill(String ipPort)
clientKill
in interface ClientCommands
public String clientGetname()
clientGetname
in interface ClientCommands
public String clientList()
clientList
in interface ClientCommands
public String clientList(ClientType type)
clientList
in interface ClientCommands
public String clientList(long... clientIds)
clientList
in interface ClientCommands
public String clientInfo()
clientInfo
in interface ClientCommands
public String clientSetname(String name)
clientSetname
in interface ClientCommands
public String migrate(String host, int port, String key, int destinationDb, int timeout)
migrate
in interface DatabaseCommands
public String migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, String... keys)
migrate
in interface DatabaseCommands
public String migrate(String host, int port, String key, int timeout)
migrate
in interface KeyCommands
public String migrate(String host, int port, int timeout, MigrateParams params, String... keys)
migrate
in interface KeyCommands
public ScanResult<String> scan(String cursor)
scan
in interface KeyCommands
public ScanResult<String> scan(String cursor, ScanParams params)
scan
in interface KeyCommands
public ScanResult<String> scan(String cursor, ScanParams params, String type)
scan
in interface KeyCommands
public ScanResult<Map.Entry<String,String>> hscan(String key, String cursor, ScanParams params)
hscan
in interface HashCommands
public ScanResult<String> sscan(String key, String cursor, ScanParams params)
sscan
in interface SetCommands
public ScanResult<Tuple> zscan(String key, String cursor, ScanParams params)
zscan
in interface SortedSetCommands
public String readonly()
readonly
in interface ClusterCommands
public String readwrite()
readwrite
in interface ClusterCommands
public String clusterNodes()
clusterNodes
in interface ClusterCommands
public String clusterReplicas(String nodeId)
clusterReplicas
in interface ClusterCommands
public String clusterMeet(String ip, int port)
clusterMeet
in interface ClusterCommands
public String clusterReset()
clusterReset
in interface ClusterCommands
public String clusterReset(ClusterResetType resetType)
ClusterCommands
resetType
can be null for default behavior.clusterReset
in interface ClusterCommands
public String clusterAddSlots(int... slots)
clusterAddSlots
in interface ClusterCommands
public String clusterDelSlots(int... slots)
clusterDelSlots
in interface ClusterCommands
public String clusterInfo()
clusterInfo
in interface ClusterCommands
public List<String> clusterGetKeysInSlot(int slot, int count)
clusterGetKeysInSlot
in interface ClusterCommands
public List<byte[]> clusterGetKeysInSlotBinary(int slot, int count)
clusterGetKeysInSlotBinary
in interface ClusterCommands
public String clusterSetSlotNode(int slot, String nodeId)
clusterSetSlotNode
in interface ClusterCommands
public String clusterSetSlotMigrating(int slot, String nodeId)
clusterSetSlotMigrating
in interface ClusterCommands
public String clusterSetSlotImporting(int slot, String nodeId)
clusterSetSlotImporting
in interface ClusterCommands
public String clusterSetSlotStable(int slot)
clusterSetSlotStable
in interface ClusterCommands
public String clusterForget(String nodeId)
clusterForget
in interface ClusterCommands
public String clusterFlushSlots()
clusterFlushSlots
in interface ClusterCommands
public long clusterKeySlot(String key)
clusterKeySlot
in interface ClusterCommands
public long clusterCountKeysInSlot(int slot)
clusterCountKeysInSlot
in interface ClusterCommands
public String clusterSaveConfig()
clusterSaveConfig
in interface ClusterCommands
public String clusterReplicate(String nodeId)
clusterReplicate
in interface ClusterCommands
public List<String> clusterSlaves(String nodeId)
ClusterCommands
CLUSTER SLAVES
command is deprecated since Redis 5.clusterSlaves
in interface ClusterCommands
public String clusterFailover()
clusterFailover
in interface ClusterCommands
public String clusterFailover(ClusterFailoverOption failoverOption)
clusterFailover
in interface ClusterCommands
public List<Object> clusterSlots()
clusterSlots
in interface ClusterCommands
public String clusterMyId()
clusterMyId
in interface ClusterCommands
public String asking()
asking
in interface ClusterCommands
public long pfadd(String key, String... elements)
pfadd
in interface HyperLogLogCommands
public long pfcount(String key)
pfcount
in interface HyperLogLogCommands
public long pfcount(String... keys)
pfcount
in interface HyperLogLogCommands
public String pfmerge(String destkey, String... sourcekeys)
pfmerge
in interface HyperLogLogCommands
public long geoadd(String key, double longitude, double latitude, String member)
geoadd
in interface GeoCommands
public long geoadd(String key, Map<String,GeoCoordinate> memberCoordinateMap)
geoadd
in interface GeoCommands
public long geoadd(String key, GeoAddParams params, Map<String,GeoCoordinate> memberCoordinateMap)
geoadd
in interface GeoCommands
public Double geodist(String key, String member1, String member2)
geodist
in interface GeoCommands
public Double geodist(String key, String member1, String member2, GeoUnit unit)
geodist
in interface GeoCommands
public List<String> geohash(String key, String... members)
geohash
in interface GeoCommands
public List<GeoCoordinate> geopos(String key, String... members)
geopos
in interface GeoCommands
public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude, double radius, GeoUnit unit)
georadius
in interface GeoCommands
public List<GeoRadiusResponse> georadiusReadonly(String key, double longitude, double latitude, double radius, GeoUnit unit)
georadiusReadonly
in interface GeoCommands
public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param)
georadius
in interface GeoCommands
public long georadiusStore(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam)
georadiusStore
in interface GeoCommands
public List<GeoRadiusResponse> georadiusReadonly(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param)
georadiusReadonly
in interface GeoCommands
public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius, GeoUnit unit)
georadiusByMember
in interface GeoCommands
public List<GeoRadiusResponse> georadiusByMemberReadonly(String key, String member, double radius, GeoUnit unit)
georadiusByMemberReadonly
in interface GeoCommands
public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param)
georadiusByMember
in interface GeoCommands
public long georadiusByMemberStore(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam)
georadiusByMemberStore
in interface GeoCommands
public List<GeoRadiusResponse> georadiusByMemberReadonly(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param)
georadiusByMemberReadonly
in interface GeoCommands
public String moduleLoad(String path)
moduleLoad
in interface ModuleCommands
public String moduleUnload(String name)
moduleUnload
in interface ModuleCommands
public List<Module> moduleList()
moduleList
in interface GenericControlCommands
moduleList
in interface ModuleCommands
public List<Long> bitfield(String key, String... arguments)
bitfield
in interface StringCommands
public List<Long> bitfieldReadonly(String key, String... arguments)
bitfieldReadonly
in interface StringCommands
public long hstrlen(String key, String field)
hstrlen
in interface HashCommands
public String memoryDoctor()
memoryDoctor
in interface ControlCommands
public Long memoryUsage(String key)
memoryUsage
in interface ControlCommands
memoryUsage
in interface KeyCommands
public Long memoryUsage(String key, int samples)
memoryUsage
in interface ControlCommands
memoryUsage
in interface KeyCommands
public StreamEntryID xadd(String key, StreamEntryID id, Map<String,String> hash)
StreamCommands
xadd
in interface StreamCommands
public StreamEntryID xadd_v2(String key, XAddParams params, Map<String,String> hash)
xadd_v2
in interface StreamCommands
public long xlen(String key)
StreamCommands
xlen
in interface StreamCommands
public List<StreamEntry> xrange(String key, StreamEntryID start, StreamEntryID end)
StreamCommands
xrange
in interface StreamCommands
start
- minimum StreamEntryID
for the retrieved range, passing null
will indicate minimum ID possible in the streamend
- maximum StreamEntryID
for the retrieved range, passing null
will indicate maximum ID possible in the streampublic List<StreamEntry> xrange(String key, StreamEntryID start, StreamEntryID end, int count)
StreamCommands
xrange
in interface StreamCommands
start
- minimum StreamEntryID
for the retrieved range, passing null
will indicate minimum ID possible in the streamend
- maximum StreamEntryID
for the retrieved range, passing null
will indicate maximum ID possible in the streamcount
- maximum number of entries returnedpublic List<StreamEntry> xrevrange(String key, StreamEntryID end, StreamEntryID start)
StreamCommands
xrevrange
in interface StreamCommands
end
- maximum StreamEntryID
for the retrieved range, passing null
will indicate maximum ID possible in the streamstart
- minimum StreamEntryID
for the retrieved range, passing null
will indicate minimum ID possible in the streampublic List<StreamEntry> xrevrange(String key, StreamEntryID end, StreamEntryID start, int count)
StreamCommands
xrevrange
in interface StreamCommands
end
- maximum StreamEntryID
for the retrieved range, passing null
will indicate maximum ID possible in the streamstart
- minimum StreamEntryID
for the retrieved range, passing null
will indicate minimum ID possible in the streamcount
- The entries with IDs matching the specified range.public List<StreamEntry> xrange(String key, String start, String end)
xrange
in interface StreamCommands
public List<StreamEntry> xrange(String key, String start, String end, int count)
xrange
in interface StreamCommands
public List<StreamEntry> xrevrange(String key, String end, String start)
xrevrange
in interface StreamCommands
public List<StreamEntry> xrevrange(String key, String end, String start, int count)
xrevrange
in interface StreamCommands
public List<Map.Entry<String,List<StreamEntry>>> xread(XReadParams xReadParams, Map<String,StreamEntryID> streams)
StreamCommands
xread
in interface StreamCommands
public long xack(String key, String group, StreamEntryID... ids)
StreamCommands
xack
in interface StreamCommands
public String xgroupCreate(String key, String groupname, StreamEntryID id, boolean makeStream)
StreamCommands
xgroupCreate
in interface StreamCommands
public String xgroupSetID(String key, String groupname, StreamEntryID id)
StreamCommands
xgroupSetID
in interface StreamCommands
public long xgroupDestroy(String key, String groupname)
StreamCommands
xgroupDestroy
in interface StreamCommands
public long xgroupDelConsumer(String key, String groupname, String consumerName)
StreamCommands
xgroupDelConsumer
in interface StreamCommands
public long xdel(String key, StreamEntryID... ids)
StreamCommands
xdel
in interface StreamCommands
public long xtrim(String key, long maxLen, boolean approximateLength)
StreamCommands
xtrim
in interface StreamCommands
public long xtrim(String key, XTrimParams params)
StreamCommands
xtrim
in interface StreamCommands
public List<Map.Entry<String,List<StreamEntry>>> xreadGroup(String groupname, String consumer, XReadGroupParams xReadGroupParams, Map<String,StreamEntryID> streams)
StreamCommands
xreadGroup
in interface StreamCommands
public StreamPendingSummary xpending(String key, String groupname)
StreamCommands
xpending
in interface StreamCommands
public List<StreamPendingEntry> xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername)
StreamCommands
xpending
in interface StreamCommands
public List<StreamPendingEntry> xpending(String key, String groupname, XPendingParams params)
StreamCommands
xpending
in interface StreamCommands
public List<StreamEntry> xclaim(String key, String group, String consumername, long minIdleTime, XClaimParams params, StreamEntryID... ids)
StreamCommands
xclaim
in interface StreamCommands
public List<StreamEntryID> xclaimJustId(String key, String group, String consumername, long minIdleTime, XClaimParams params, StreamEntryID... ids)
StreamCommands
xclaimJustId
in interface StreamCommands
public Map.Entry<StreamEntryID,List<StreamEntry>> xautoclaim(String key, String group, String consumerName, long minIdleTime, StreamEntryID start, XAutoClaimParams params)
StreamCommands
xautoclaim
in interface StreamCommands
key
- Stream Keygroup
- Consumer GroupconsumerName
- Consumer name to transfer the auto claimed entriesminIdleTime
- Entries pending more than minIdleTime will be transferred ownershipstart
- StreamEntryID
- Entries >= start will be transferred ownership, passing null
will indicate '-'params
- XAutoClaimParams
public Map.Entry<StreamEntryID,List<StreamEntryID>> xautoclaimJustId(String key, String group, String consumerName, long minIdleTime, StreamEntryID start, XAutoClaimParams params)
StreamCommands
xautoclaimJustId
in interface StreamCommands
key
- Stream Keygroup
- Consumer GroupconsumerName
- Consumer name to transfer the auto claimed entriesminIdleTime
- Entries pending more than minIdleTime will be transferred ownershipstart
- StreamEntryID
- Entries >= start will be transferred ownership, passing null
will indicate '-'params
- XAutoClaimParams
public StreamInfo xinfoStream(String key)
StreamCommands
xinfoStream
in interface StreamCommands
key
- Stream nameStreamInfo
that contains information about the streampublic List<StreamGroupInfo> xinfoGroup(String key)
StreamCommands
xinfoGroup
in interface StreamCommands
key
- Stream nameStreamGroupInfo
containing information about groupspublic List<StreamConsumersInfo> xinfoConsumers(String key, String group)
StreamCommands
xinfoConsumers
in interface StreamCommands
key
- Stream namegroup
- Group nameStreamConsumersInfo
containing information about consumers that belong
to the the grouppublic Object sendCommand(ProtocolCommand cmd, String... args)
public Object sendBlockingCommand(ProtocolCommand cmd, String... args)
Copyright © 2021. All rights reserved.