Class Jedis
- All Implemented Interfaces:
Closeable,AutoCloseable,AccessControlLogBinaryCommands,AccessControlLogCommands,BitBinaryCommands,BitCommands,ClientBinaryCommands,ClientCommands,ClusterCommands,ConfigCommands,ControlBinaryCommands,ControlCommands,DatabaseCommands,FunctionBinaryCommands,FunctionCommands,GenericControlCommands,GeoBinaryCommands,GeoCommands,HashBinaryCommands,HashCommands,HyperLogLogBinaryCommands,HyperLogLogCommands,JedisBinaryCommands,JedisCommands,KeyBinaryCommands,KeyCommands,ListBinaryCommands,ListCommands,ModuleCommands,ScriptingControlCommands,ScriptingKeyBinaryCommands,ScriptingKeyCommands,SentinelCommands,ServerCommands,SetBinaryCommands,SetCommands,SlowlogCommands,SortedSetBinaryCommands,SortedSetCommands,StreamBinaryCommands,StreamCommands,StringBinaryCommands,StringCommands
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CommandObjectsprotected final Connectionprivate intprotected static final byte[][]private booleanprivate booleanprivate Pipelineprivate Transaction -
Constructor Summary
ConstructorsConstructorDescriptionJedis()This constructor only accepts a URI string.Jedis(String host, int port, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) Jedis(String host, int port, int timeout, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) 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, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) Jedis(String host, int port, JedisClientConfig config) 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, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) Jedis(URI uri, JedisClientConfig config) Jedis(Connection connection) Jedis(HostAndPort hp) Jedis(HostAndPort hostPort, JedisClientConfig config) Jedis(JedisSocketFactory jedisSocketFactory) Jedis(JedisSocketFactory jedisSocketFactory, JedisClientConfig clientConfig) -
Method Summary
Modifier and TypeMethodDescriptionaclCat()Show the available ACL categories.List<byte[]> aclCat(byte[] category) Show the available ACLs for a given category.Show the available ACLs for a given category.List<byte[]> Show the available ACL categories.longaclDelUser(byte[] name) Delete the specified user, from the ACL.longaclDelUser(byte[] name, byte[]... names) Delete the specified users, from the ACL.longaclDelUser(String name) Delete the specified user, from the ACL.longaclDelUser(String name, String... names) Delete the specified users, from the ACL.aclDryRun(String username, CommandArguments commandArgs) byte[]aclDryRunBinary(byte[] username, byte[] command, byte[]... args) byte[]aclDryRunBinary(byte[] username, CommandArguments commandArgs) Generate a random passwordaclGenPass(int bits) Generate a random passwordbyte[]Generate a random passwordbyte[]aclGenPassBinary(int bits) Generate a random passwordaclGetUser(byte[] name) The command returns all the rules defined for an existing ACL user.aclGetUser(String name) The command returns all the rules defined for an existing ACL user.aclList()Returns the currently active ACL rules on the Redis ServerList<byte[]> Returns the currently active ACL rules on the Redis ServeraclLoad()This function tells Redis to reload its external ACL rules, when Redis is configured with an external ACL fileaclLog()Shows the recent ACL security events.aclLog(int limit) Shows the recent limit ACL security events.List<byte[]> Shows the recent ACL security events.List<byte[]> aclLogBinary(int limit) Shows the recent limit ACL security events.Reset the script event logaclSave()Save the currently defined in-memory ACL to disk.aclSetUser(byte[] name) Create an ACL for the specified user with the default rules.aclSetUser(byte[] name, byte[]... keys) Create an ACL for the specified user, while specifying the rules.aclSetUser(String name) Create an ACL for the specified user with the default rules.aclSetUser(String name, String... params) Create an ACL for the specified user, while specifying the rules.aclUsers()Shows a list of all usernames currently configured with access control lists (ACL).List<byte[]> Shows a list of all usernames currently configured with access control lists (ACL).Returns the username used to authenticate the current connection.byte[]Returns the username used to authenticate the current connection.longappend(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.longIf the key already exists and is a string, this command appends the provided value at the end of the string.asking()Request for authentication in a password protected Redis server.Request for authentication with a Redis Server that is using ACL where user are authenticated with username and password.Rewrite the append only file in background when it gets too big.bgsave()Asynchronously save the DB on disk.longbitcount(byte[] key) longbitcount(byte[] key, long start, long end) longbitcount(byte[] key, long start, long end, BitCountOption option) longBitcount Command Count the number of set bits (population counting) in a string.longBitcount Command Count the number of set bits (population counting) in a string only in an interval start and end.longbitcount(String key, long start, long end, BitCountOption option) bitfield(byte[] key, byte[]... arguments) Bitfield Command The command treats a Redis string as an array of bits, and is capable of addressing specific integer fields of varying bit widths and arbitrary non (necessary) aligned offset.bitfieldReadonly(byte[] key, byte[]... arguments) bitfieldReadonly(String key, String... arguments) The readonly version ofBITFIELDlonglongBitop Command Perform a bitwise operation between multiple keys (containing string values) and store the result in the destKey.longbitpos(byte[] key, boolean value) longbitpos(byte[] key, boolean value, BitPosParams params) longBitpos Command Return the position of the first bit set to 1 or 0 in a string.longbitpos(String key, boolean value, BitPosParams params) Bitpos Command Return the position of the first bit set to 1 or 0 in a string.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 availableblmove(String srcKey, String 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 availableblmpop(long timeout, ListDirection direction, byte[]... keys) blmpop(long timeout, ListDirection direction, int count, byte[]... keys) blmpop(long timeout, ListDirection direction, int count, String... keys) blmpop(long timeout, ListDirection direction, String... keys) List<byte[]> blpop(double timeout, byte[]... keys) The blocking version ofListCommands.lpop(String)LPOP} because it blocks the connection when there are no elements to pop from any of the given lists.List<byte[]> blpop(int timeout, byte[]... keys) BLPOP (and BRPOP) is a blocking list pop primitive.BLPOP (and BRPOP) is a blocking list pop primitive.List<byte[]> brpop(double timeout, byte[]... keys) The blocking version ofListCommands.rpop(String)RPOP} because it blocks the connection when there are no elements to pop from any of the given lists.List<byte[]> brpop(int timeout, byte[]... keys) BLPOP (and BRPOP) is a blocking list pop primitive.BLPOP (and BRPOP) is a blocking list pop primitive.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 availablebrpoplpush(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 availablebzmpop(long timeout, SortedSetOption option, byte[]... keys) bzmpop(long timeout, SortedSetOption option, int count, byte[]... keys) bzmpop(long timeout, SortedSetOption option, int count, String... keys) bzmpop(long timeout, SortedSetOption option, String... keys) List<byte[]> bzpopmax(double timeout, byte[]... keys) The blocking version ofZPOPMAXList<byte[]> bzpopmin(double timeout, byte[]... keys) The blocking version ofZPOPMINprotected voidReturns the name of the current connection as set by CLIENT SETNAMEbyte[]Returns the name of the current connection as set by CLIENT SETNAMElongclientId()Returns the ID of the current connection.Returns information and statistics about the current client connection in a mostly human readable format.byte[]Returns information and statistics about the current client connection in a mostly human readable format.clientKill(byte[] ipPort) Close a given client connection.clientKill(String ipPort) Close a given client connection.clientKill(String ip, int port) Close a given client connection.longclientKill(ClientKillParams params) Close a given client connection.Returns information and statistics about the client connections server in a mostly human readable format.clientList(long... clientIds) Returns information and statistics about the client connections server in a mostly human readable format filter by client ids.clientList(ClientType type) Returns information and statistics about the client connections server in a mostly human readable format filter by client type.byte[]Returns information and statistics about the client connections server in a mostly human readable format.byte[]clientListBinary(long... clientIds) Returns information and statistics about the client connections server in a mostly human readable format filter by client ids.byte[]clientListBinary(ClientType type) Returns information and statistics about the client connections server in a mostly human readable format filter by client type.private byte[][]clientListParams(long... clientIds) Turn off the client eviction mode for the current connection.Turn on the client eviction mode for the current connection.Turn off CLIENT NO-TOUCHTurn on CLIENT NO-TOUCHclientPause(long timeout) A connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds)clientPause(long timeout, ClientPauseMode mode) A connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds)clientSetInfo(ClientAttributeOption attr, byte[] value) client set info command Since redis 7.2clientSetInfo(ClientAttributeOption attr, String value) client set info command Since redis 7.2clientSetname(byte[] name) Assigns a name to the current connection.clientSetname(String name) Assigns a name to the current connection.longclientUnblock(long clientId) Unblock a connection blocked in a blocking command from a different connection.longclientUnblock(long clientId, UnblockType unblockType) Unblock a connection blocked in a blocking command from a different connection.CLIENT UNPAUSE is used to resume command processing for all clients that were paused by CLIENT PAUSE.voidclose()clusterAddSlots(int... slots) clusterAddSlotsRange(int... ranges) Takes a list of slot ranges (specified by start and end slots) to assign to the nodeAdvance the cluster config epoch.longclusterCountFailureReports(String nodeId) longclusterCountKeysInSlot(int slot) clusterDelSlots(int... slots) clusterDelSlotsRange(int... ranges) Takes a list of slot ranges (specified by start and end slots) to remove to the node.clusterFailover(ClusterFailoverOption failoverOption) clusterForget(String nodeId) clusterGetKeysInSlot(int slot, int count) List<byte[]> clusterGetKeysInSlotBinary(int slot, int count) longclusterKeySlot(String key) return the information of all such peer links as an array, where each array element is a map that contains attributes and their values for an individual link.clusterMeet(String ip, int port) clusterReplicas(String nodeId) clusterReplicate(String nodeId) clusterReset(ClusterResetType resetType) resetTypecan be null for default behavior.clusterSetConfigEpoch(long configEpoch) Set a specific config epoch in a fresh node.clusterSetSlotImporting(int slot, String nodeId) clusterSetSlotMigrating(int slot, String nodeId) clusterSetSlotNode(int slot, String nodeId) clusterSetSlotStable(int slot) clusterSlaves(String nodeId) Deprecated.longcommandDocs(String... commands) commandGetKeys(String... command) commandGetKeysAndFlags(String... command) commandInfo(String... commands) commandListFilterBy(CommandListFilterByParams filterByParams) List<byte[]> configGet(byte[] pattern) Retrieve the configuration of a running Redis server.List<byte[]> configGet(byte[]... patterns) Used to read the configuration parameters of Redis server.Retrieve the configuration of a running Redis server.Used to read the configuration parameters of Redis server.Reset the stats returned by INFOThe 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.configSet(byte[]... parameterValues) configSet(byte[] parameter, byte[] value) Alter the configuration of a running Redis server.Alter the configuration of a running Redis server.voidconnect()booleancopy(byte[] srcKey, byte[] dstKey, boolean replace) COPY source destination [DB destination-db] [REPLACE]booleancopy(byte[] srcKey, byte[] dstKey, int db, boolean replace) COPY source destination [DB destination-db] [REPLACE]booleanCOPY source destination [REPLACE]booleanCOPY source destination [DB destination-db] [REPLACE]longdbSize()Return the number of keys in the currently selected database.longdecr(byte[] key) Decrement the number stored at key by one.longDecrement the number stored at key by one.longdecrBy(byte[] key, long decrement) DECRBY work just likeDECRbut instead to decrement by 1 the decrement is integer.longIDECRBY work just likeINCRbut instead to decrement by 1 the decrement is integer.longdel(byte[] key) longdel(byte[]... keys) Remove the specified keys.longDel Command Remove the specified key.longRemove the specified keys.voidClosing the socket will disconnect the server connection.byte[]dump(byte[] key) byte[]Dump Command Serialize the value stored at key in a Redis-specific format and return it to the user.byte[]echo(byte[] string) eval(byte[] script) eval(byte[] script, int keyCount, byte[]... params) Evaluates scripts using the Lua interpreter built into Redis starting from version 2.6.0.Eval Command Use to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.Eval Command Use to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.Eval Command Use to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.evalReadonly(byte[] script, List<byte[]> keys, List<byte[]> args) Readonly version ofEVALevalsha(byte[] sha1) evalsha(byte[] sha1, int keyCount, byte[]... params) EvalSha Command Similar toEVAL, but the script cached on the server side by its SHA1 digest.EvalSha Command Similar toScriptingKeyCommands.eval(String, int, String...)EVAL}, but the script cached on the server side by its SHA1 digest.EvalSha Command Similar toScriptingKeyCommands.eval(String, List, List)EVAL}, but the script cached on the server side by its SHA1 digest.evalshaReadonly(byte[] sha1, List<byte[]> keys, List<byte[]> args) Readonly version ofEVALbooleanexists(byte[] key) Test if the specified key exists.longexists(byte[]... keys) Test if the specified keys exist.booleanTest if the specified key exists.longTest if the specified keys exist.longexpire(byte[] key, long seconds) Set a timeout on the specified key.longexpire(byte[] key, long seconds, ExpiryOption expiryOption) longSet a timeout on the specified key.longexpire(String key, long seconds, ExpiryOption expiryOption) Similar toEXPIREbut with optional expiry setting.longexpireAt(byte[] key, long unixTime) EXPIREAT works exactly likeEXPIREbut 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).longexpireAt(byte[] key, long unixTime, ExpiryOption expiryOption) longEXPIREAT works exactly likeEXPIREbut 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).longexpireAt(String key, long unixTime, ExpiryOption expiryOption) Similar toEXPIREATbut withExpiryOption.longexpireTime(byte[] key) longexpireTime(String key) Returns the absolute Unix timestamp (since January 1, 1970) in seconds at which the given key will expire.failover()failover(FailoverParams failoverParams) Invoke a function.Invoke a function.fcallReadonly(byte[] name, List<byte[]> keys, List<byte[]> args) This is a read-only variant of theFCALLcommand that cannot execute commands that modify data.flushAll()Delete all the keys of all the existing databases, not just the currently selected one.Delete all the keys of all the existing databases, not just the currently selected one.flushDB()Delete all the keys of the currently selected DB.Delete all the keys of the currently selected DB.functionDelete(byte[] libraryName) This command deletes the library called library-name and all functions in it.functionDelete(String libraryName) This command deletes the library called library-name and all functions in it.byte[]Return the serialized payload of loaded libraries.Deletes all the libraries, unless called with the optional mode argument, the 'lazyfree-lazy-user-flush' configuration directive sets the effective behavior.functionFlush(FlushMode mode) Deletes all the libraries, unless called with the optional mode argument, the 'lazyfree-lazy-user-flush' configuration directive sets the effective behavior.Kill a function that is currently executing.Return information about the functions and libraries.functionList(byte[] libraryNamePattern) Return information about the functions and libraries.functionList(String libraryNamePattern) Return information about the functions and libraries.Return information about the functions and libraries.Similar toFUNCTION LISTbut include the libraries source implementation in the reply.functionListWithCode(byte[] libraryNamePattern) Similar toFUNCTION LISTbut include the libraries source implementation in the reply.functionListWithCode(String libraryNamePattern) Similar toFUNCTION LISTbut include the libraries source implementation in the reply.Similar toFUNCTION LISTbut include the libraries source implementation in the reply.functionLoad(byte[] functionCode) Load a library to Redis.functionLoad(String functionCode) Load a library to Redis.functionLoadReplace(byte[] functionCode) Load a library to Redis.functionLoadReplace(String functionCode) Load a library to Redis.functionRestore(byte[] serializedValue) Restore libraries from the serialized payload.functionRestore(byte[] serializedValue, FunctionRestorePolicy policy) Restore libraries from the serialized payload.Return information about the function that's currently running and information about the available execution engines.Return information about the function that's currently running and information about the available execution engines.longgeoadd(byte[] key, double longitude, double latitude, byte[] member) longgeoadd(byte[] key, Map<byte[], GeoCoordinate> memberCoordinateMap) longgeoadd(byte[] key, GeoAddParams params, Map<byte[], GeoCoordinate> memberCoordinateMap) longAdds the specified geospatial item (longitude, latitude, member) to the specified key.longgeoadd(String key, Map<String, GeoCoordinate> memberCoordinateMap) Adds the specified geospatial items (in memberCoordinateMap) to the specified key.longgeoadd(String key, GeoAddParams params, Map<String, GeoCoordinate> memberCoordinateMap) Adds the specified geospatial items (in memberCoordinateMap) to the specified key.geodist(byte[] key, byte[] member1, byte[] member2) Return the distance between two members in the geospatial index represented by the sorted set.Return the distance between two members in the geospatial index represented by the sorted set.List<byte[]> geohash(byte[] key, byte[]... members) Return valid Geohash strings representing the position of the given members.geopos(byte[] key, byte[]... members) Return the positions (longitude,latitude) of all the specified members.georadius(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param) Return the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified with the center location and the radius.georadius(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param) Return the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified with the center location and the radius.georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit) georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param) georadiusByMember(String key, String member, double radius, GeoUnit unit) This command is exactly likeGEORADIUSwith the sole difference that instead of taking, as the center of the area to query, a longitude and latitude value, it takes the name of a member already existing inside the geospatial index represented by the sorted set.georadiusByMember(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param) This command is exactly likeGEORADIUSwith the sole difference that instead of taking, as the center of the area to query, a longitude and latitude value, it takes the name of a member already existing inside the geospatial index represented by the sorted set.georadiusByMemberReadonly(byte[] key, byte[] member, double radius, GeoUnit unit) georadiusByMemberReadonly(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param) georadiusByMemberReadonly(String key, String member, double radius, GeoUnit unit) Readonly version ofGEORADIUSBYMEMBERgeoradiusByMemberReadonly(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param) Readonly version ofGEORADIUSBYMEMBERlonggeoradiusByMemberStore(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam) longgeoradiusByMemberStore(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam) This command is exactly likeGEORADIUSBYMEMBERbut storing the results at the destination key (provided withstoreParam).georadiusReadonly(byte[] key, double longitude, double latitude, double radius, GeoUnit unit) georadiusReadonly(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param) georadiusReadonly(String key, double longitude, double latitude, double radius, GeoUnit unit) Readonly version ofGEORADIUS,georadiusReadonly(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param) Readonly version ofGEORADIUS,longgeoradiusStore(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam) longgeoradiusStore(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam) This command is exactly likeGEORADIUSbut storing the results at the destination key (provided withstoreParam).geosearch(byte[] key, GeoCoordinate coord, double width, double height, GeoUnit unit) geosearch(byte[] key, GeoCoordinate coord, double radius, GeoUnit unit) geosearch(byte[] key, GeoSearchParam params) Return the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified by a given shape.Return the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified by a given shape.geosearch(String key, GeoCoordinate coord, double width, double height, GeoUnit unit) Return the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified by a given shape.geosearch(String key, GeoCoordinate coord, double radius, GeoUnit unit) Return the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified by a given shape.geosearch(String key, GeoSearchParam params) Return the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified by a given shape.longgeosearchStore(byte[] dest, byte[] src, byte[] member, double width, double height, GeoUnit unit) longgeosearchStore(byte[] dest, byte[] src, byte[] member, double radius, GeoUnit unit) longgeosearchStore(byte[] dest, byte[] src, GeoCoordinate coord, double width, double height, GeoUnit unit) longgeosearchStore(byte[] dest, byte[] src, GeoCoordinate coord, double radius, GeoUnit unit) longgeosearchStore(byte[] dest, byte[] src, GeoSearchParam params) longgeosearchStore(String dest, String src, String member, double width, double height, GeoUnit unit) This command is exactly likeGEOSEARCHbut storing the results at dest.longgeosearchStore(String dest, String src, String member, double radius, GeoUnit unit) This command is exactly likeGEOSEARCHbut storing the results at dest.longgeosearchStore(String dest, String src, GeoCoordinate coord, double width, double height, GeoUnit unit) This command is exactly likeGEOSEARCHbut storing the results at dest.longgeosearchStore(String dest, String src, GeoCoordinate coord, double radius, GeoUnit unit) This command is exactly likeGEOSEARCHbut storing the results at dest.longgeosearchStore(String dest, String src, GeoSearchParam params) This command is exactly likeGEOSEARCHbut storing the results at dest.longgeosearchStoreStoreDist(byte[] dest, byte[] src, GeoSearchParam params) longgeosearchStoreStoreDist(String dest, String src, GeoSearchParam params) This command is exactly likeGEOSEARCHSTOREbut storing the results with their destinations from the center point.byte[]get(byte[] key) Get the value of the specified key.Get the value of the specified key.booleangetbit(byte[] key, long offset) Returns the bit value at offset in the string value stored at keybooleanReturns the bit value at offset in the string value stored at keyintgetDB()byte[]getDel(byte[] key) Get the value of key and delete the key.Get the value of key and delete the key.byte[]getEx(byte[] key, GetExParams params) getEx(String key, GetExParams params) GetEx Command Get the value of key and optionally set its expiration.protected static byte[][]getParamsWithBinary(List<byte[]> keys, List<byte[]> args) byte[]getrange(byte[] key, long startOffset, long endOffset) GetRange Command Return the substring of the string value stored at key, determined by the offsets start and end (both are inclusive).byte[]getSet(byte[] key, byte[] value) GETSET is an atomic set this value and return the old value command.GETSET is an atomic set this value and return the old value command.longhdel(byte[] key, byte[]... fields) Remove the specified field from an hash stored at key.longRemove the specified field(s) from a hash stored at key.booleanhexists(byte[] key, byte[] field) Test for existence of a specified field in a hash.booleanTest 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.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.Return all the fields and associated values in a hash.longhincrBy(byte[] key, byte[] field, long value) Increment the number stored at field in the hash at key by value.longIncrement the number stored at field in the hash at key by value.doublehincrByFloat(byte[] key, byte[] field, double value) Increment the number stored at field in the hash at key by a double precision floating point value.doublehincrByFloat(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.Return all the fields in a hash.longhlen(byte[] key) Return the number of items in a hash.longReturn the number of items in a hash.List<byte[]> hmget(byte[] key, byte[]... fields) Retrieve the values associated to the specified fields.Retrieve the values associated to the specified fields.Set the respective fields to the respective values.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.hrandfield(String key) Get one random field from a hash.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.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) hscan(String key, String cursor, ScanParams params) longhset(byte[] key, byte[] field, byte[] value) Set the specified hash field to the specified value.longlongSet the specified hash field to the specified value.longlonghsetnx(byte[] key, byte[] field, byte[] value) Set the specified hash field to the specified value if the field not exists.longSet the specified hash field to the specified value if the field not exists.longhstrlen(byte[] key, byte[] field) longList<byte[]> hvals(byte[] key) Return all the values in a hash.Return all the values in a hash.longincr(byte[] key) Increment the number stored at key by one.longIncrement the number stored at key by one.longincrBy(byte[] key, long increment) INCRBY work just likeINCRbut instead to increment by 1 the increment is integer.longINCRBY work just likeINCRbut instead to increment by 1 the increment is integer.doubleincrByFloat(byte[] key, double increment) INCRBYFLOAT work just likeincrBy(byte[], long)INCRBY} but increments by floats instead of integers.doubleincrByFloat(String key, double increment) INCRBYFLOATinfo()Provide information and statistics about the server.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.booleanisBroken()booleanprivate static byte[][]joinParameters(byte[] first, byte[][] rest) private static byte[][]joinParameters(byte[] first, byte[] second, byte[][] rest) private static byte[][]joinParameters(int... params) private static String[]joinParameters(String first, String[] rest) private static String[]joinParameters(String first, String second, String[] rest) Set<byte[]> keys(byte[] pattern) Returns all the keys matching the glob-style pattern as space separated strings.Keys Command Returns all the keys matching the glob-style pattern as space separated strings.longlastsave()Return the UNIX time stamp of the last successfully saving of the dataset on disk.The LATENCY DOCTOR command reports about different latency-related issues and advises about possible remedies.Calculate the longest common subsequence of keyA and keyB.Calculate the longest common subsequence of keyA and keyB.byte[]lindex(byte[] key, long index) Return the specified element of the list stored at the specified key.Return the specified element of the list stored at the specified key.longlinsert(byte[] key, ListPosition where, byte[] pivot, byte[] value) longlinsert(String key, ListPosition where, String pivot, String value) Inserts element in the list stored at key either before or after the reference value pivot.longllen(byte[] key) Return the length of the list stored at the specified key.longReturn 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 itlmove(String srcKey, String dstKey, ListDirection from, ListDirection to) Pop an element from a list, push it to another list and return itlmpop(ListDirection direction, byte[]... keys) lmpop(ListDirection direction, int count, byte[]... keys) lmpop(ListDirection direction, int count, String... keys) lmpop(ListDirection direction, String... keys) lolwut()lolwut(LolwutParams lolwutParams) 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) Atomically return and remove the first (LPOP) or last (RPOP) element of the list.Atomically return and remove the first (LPOP) or last (RPOP) element of the list.lpos(byte[] key, byte[] element) Returns the index of the first matching element inside a redis list.lpos(byte[] key, byte[] element, LPosParams params) In case there are multiple matches Rank option specifies the "rank" of the element to return.lpos(byte[] key, byte[] element, LPosParams params, long count) Count will return list of position of all the first N matching elements.Returns the index of the first matching element inside a redis list.lpos(String key, String element, LPosParams params) In case there are multiple matches Rank option specifies the "rank" of the element to return.lpos(String key, String element, LPosParams params, long count) Returns the index of matching elements inside a Redis list.longlpush(byte[] key, byte[]... strings) Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key.longAdd the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key.longlpushx(byte[] key, byte[]... strings) longInserts specified values at the head of the list stored at key.List<byte[]> lrange(byte[] key, long start, long stop) Return the specified elements of the list stored at the specified key.Return the specified elements of the list stored at the specified key.longlrem(byte[] key, long count, byte[] value) Remove the first count occurrences of the value element from the list.longRemove the first count occurrences of the value element from the list.lset(byte[] key, long index, byte[] value) Set a new value as the element at index position of the List at key.Set a new value as the element at index position of the List at key.ltrim(byte[] key, long start, long stop) Trim an existing list so that it will contain only the specified range of elements specified.Trim an existing list so that it will contain only the specified range of elements specified.Reports about different memory-related issues that the Redis server experiences, and advises about possible remedies.byte[]Reports about different memory-related issues that the Redis server experiences, and advises about possible remedies.Attempts to purge dirty pages so these can be reclaimed by the allocator.Returns an Array reply about the memory usage of the server.memoryUsage(byte[] key) Reports the number of bytes that a key and its value require to be stored in RAM.memoryUsage(byte[] key, int samples) Reports the number of bytes that a key and its value require to be stored in RAM.memoryUsage(String key) Memory Usage Command Report the number of bytes that a key and its value require to be stored in RAM.memoryUsage(String key, int samples) Memory Usage Command Report the number of bytes that a key and its value require to be stored in RAM.List<byte[]> mget(byte[]... keys) Get the values of all the specified keys.Get the values of all the specified keys.Binary version ofMIGRATE.migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, byte[]... keys) Binary version ofMIGRATE.migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, String... keys) Migrate Command Atomically transfer a key from a source Redis instance to a destination Redis instance.migrate(String host, int port, int timeout, MigrateParams params, byte[]... keys) migrate(String host, int port, int timeout, MigrateParams params, String... keys) Migrate Command Atomically transfer a key from a source Redis instance to a destination Redis instance.Migrate Command Atomically transfer a key from a source Redis instance to a destination Redis instance.Migrate Command Atomically transfer a key from a source Redis instance to a destination Redis instance.Return information about the modules loaded to the server.moduleLoad(String path) Load and initialize the Redis module from the dynamic library specified by the path argument.moduleLoad(String path, String... args) Load and initialize the Redis module from the dynamic library specified by the path argument.moduleLoadEx(String path, ModuleLoadExParams params) Loads a module from a dynamic library at runtime with configuration directives.moduleUnload(String name) Unload the module specified by name.voidmonitor(JedisMonitor jedisMonitor) Dump all the received requests in real time.longmove(byte[] key, int dbIndex) Move the specified key from the currently selected DB to the specified destination DB.longMove the specified key from the currently selected DB to the specified destination DB.mset(byte[]... keysvalues) Set the the respective keys to the respective values.Set the the respective keys to the respective values.longmsetnx(byte[]... keysvalues) Set the respective keys to the respective values.longSet the the respective keys to the respective values.multi()byte[]objectEncoding(byte[] key) Returns the internal encoding for the Redis object stored atkey.objectEncoding(String key) Object Encoding Command Return the internal encoding for the Redis object stored at key.objectFreq(byte[] key) Returns the logarithmic access frequency counter of a Redis object stored atkey.objectFreq(String key) Object Freq Command Return the logarithmic access frequency counter of a Redis object stored at key.Returns the object subcommands and usages.List<byte[]> Returns the object subcommands and usages.objectIdletime(byte[] key) Returns the time in seconds since the last access to the value stored atkey.objectIdletime(String key) Object IdleTime Command Return the time in seconds since the last access to the value stored at key.objectRefcount(byte[] key) Returns the reference count of the stored atkey.objectRefcount(String key) Object Refcount Command Return the reference count of the stored at key.longpersist(byte[] key) Undo aexpireat turning the expire key into a normal key.longUndo aexpireat turning the expire key into a normal key.longpexpire(byte[] key, long milliseconds) Set a timeout on the specified key.longpexpire(byte[] key, long milliseconds, ExpiryOption expiryOption) longPExpire Command This command works exactly likeEXPIREbut the time to live of the key is specified in milliseconds instead of seconds.longpexpire(String key, long milliseconds, ExpiryOption expiryOption) Similar toEXPIREbut with optional expiry setting.longpexpireAt(byte[] key, long millisecondsTimestamp) longpexpireAt(byte[] key, long millisecondsTimestamp, ExpiryOption expiryOption) longThis command works exactly likeEXPIREATbut Unix time at which the key will expire is specified in milliseconds instead of seconds.longpexpireAt(String key, long millisecondsTimestamp, ExpiryOption expiryOption) longpexpireTime(byte[] key) longpexpireTime(String key) Similar toEXPIRETIMEbut returns the absolute Unix expiration timestamp in milliseconds instead of seconds.longpfadd(byte[] key, byte[]... elements) longlongpfcount(byte[] key) longpfcount(byte[]... keys) longlongpfmerge(byte[] destkey, byte[]... sourcekeys) ping()This command is often used to test if a connection is still alive, or to measure latency.byte[]ping(byte[] message) Works same asping()but returns argument message instead ofPONG.Works same asping()but returns argument message instead of PONG.psetex(byte[] key, long milliseconds, byte[] value) PSETEX works exactly likesetex(byte[], long, byte[])with the sole difference that the expire time is specified in milliseconds instead of seconds.PSETEX works exactly likesetex(String, long, String)with the sole difference that the expire time is specified in milliseconds instead of seconds.voidpsubscribe(BinaryJedisPubSub jedisPubSub, byte[]... patterns) voidpsubscribe(JedisPubSub jedisPubSub, String... patterns) longpttl(byte[] key) longPTTL Command The PTTL command returns the remaining time to live in milliseconds of a key that has anEXPIREset.longpublish(byte[] channel, byte[] message) longpubsubChannels(String pattern) pubsubNumSub(String... channels) quit()Deprecated.The QUIT command is deprecated, see #11420.byte[]Return a randomly selected key from the currently selected DB.Return a randomly selected key from the currently selected DB.readonly()rename(byte[] oldkey, byte[] newkey) Atomically renames the key oldkey to newkey.Atomically renames the key oldkey to newkey.longrenamenx(byte[] oldkey, byte[] newkey) Rename oldkey into newkey but fails if the destination key newkey already exists.longRename oldkey into newkey but fails if the destination key newkey already exists.The REPLICAOF command can change the replication settings of a replica on the fly.REPLICAOF NO ONE will stop replication, turning the server into a MASTER, but will not discard the replication.voidrestore(byte[] key, long ttl, byte[] serializedValue) restore(byte[] key, long ttl, byte[] serializedValue, RestoreParams params) Restore Command Create a key associated with a value that is obtained by deserializing the provided serialized value (obtained viaDUMP).restore(String key, long ttl, byte[] serializedValue, RestoreParams params) Restore Command Create a key associated with a value that is obtained by deserializing the provided serialized value (obtained viaDUMP).role()Provide information on the role of a Redis instance in the context of replication, by returning if the instance is currently a master, slave, or sentinel.Provide information on the role of a Redis instance in the context of replication, by returning if the instance is currently a master, slave, or sentinel.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) Atomically return and remove the first (LPOP) or last (RPOP) element of the list.Atomically return and remove the first (LPOP) or last (RPOP) element of the list.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.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.longrpush(byte[] key, byte[]... strings) Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key.longAdd the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key.longrpushx(byte[] key, byte[]... strings) longInserts specified values at the tail of the list stored at key.longsadd(byte[] key, byte[]... members) Add the specified member to the set value stored at key.longAdd the specified member to the set value stored at key.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) scan(String cursor, ScanParams params) scan(String cursor, ScanParams params, String type) longscard(byte[] key) Return the set cardinality (number of elements).longReturn the set cardinality (number of elements).scriptExists(byte[] sha1) scriptExists(byte[]... sha1) scriptExists(String sha1) scriptExists(String... sha1) scriptFlush(FlushMode flushMode) byte[]scriptLoad(byte[] script) scriptLoad(String script) Set<byte[]> sdiff(byte[]... keys) Return the difference between the Set stored at key1 and all the Sets key2, ..., keyNReturn the difference between the Set stored at key1 and all the Sets key2, ..., keyNlongsdiffstore(byte[] dstkey, byte[]... keys) This command works exactly likeSDIFFbut instead of being returned the resulting set is stored in dstkey.longsdiffstore(String dstkey, String... keys) This command works exactly likeSDIFFbut instead of being returned the resulting set is stored in dstkey.select(int index) Select the DB with having the specified zero-based numeric index.sendBlockingCommand(ProtocolCommand cmd, byte[]... args) sendBlockingCommand(ProtocolCommand cmd, String... args) sendCommand(ProtocolCommand cmd, byte[]... args) sendCommand(ProtocolCommand cmd, String... args) sentinelFailover(String masterName) sentinelGetMasterAddrByName(String masterName) redis 127.0.0.1:26381> sentinel get-master-addr-by-name mymaster 1) "127.0.0.1" 2) "6379"sentinelMaster(String masterName) redis 127.0.0.1:26381> sentinel masters 1) 1) "name" 2) "mymaster" 3) "ip" 4) "127.0.0.1" 5) "port" 6) "6379" 7) "runid" 8) "93d4d4e6e9c06d0eea36e27f31924ac26576081d" 9) "flags" 10) "master" 11) "pending-commands" 12) "0" 13) "last-ok-ping-reply" 14) "423" 15) "last-ping-reply" 16) "423" 17) "info-refresh" 18) "6107" 19) "num-slaves" 20) "1" 21) "num-other-sentinels" 22) "2" 23) "quorum" 24) "2"sentinelMonitor(String masterName, String ip, int port, int quorum) sentinelRemove(String masterName) sentinelReplicas(String masterName) sentinelReset(String pattern) redis 127.0.0.1:26381> sentinel reset mymaster (integer) 1sentinelSentinels(String masterName) sentinelSet(String masterName, Map<String, String> parameterMap) sentinelSlaves(String masterName) Deprecated.set(byte[] key, byte[] value) Set the string value as value of the key.Set the string value as value of the key.Set the string value as value of the key.Set the string value as value of the key.booleansetbit(byte[] key, long offset, boolean value) Sets or clears the bit at offset in the string value stored at keybooleanSets or clears the bit at offset in the string value stored at keyprotected voidsetDataSource(Pool<Jedis> jedisPool) setex(byte[] key, long seconds, byte[] value) byte[]WARNING:SetParams.get()MUST NOT be used with this method.WARNING:SetParams.get()MUST NOT be used with this method.longsetnx(byte[] key, byte[] value) SETNX works exactly likeSETwith the only difference that if the key already exists no operation is performed.longSETNX works exactly likeSETwith the only difference that if the key already exists no operation is performed.longsetrange(byte[] key, long offset, byte[] value) longSetRange Command GETRANGE overwrite part of the string stored at key, starting at the specified offset, for the entire length of value.voidshutdown()Synchronously save the DB on disk, then shutdown the server.voidDeprecated.voidshutdown(ShutdownParams shutdownParams) Set<byte[]> sinter(byte[]... keys) Return the members of a set resulting from the intersection of all the sets hold at the specified keys.Return the members of a set resulting from the intersection of all the sets hold at the specified keys.longsintercard(byte[]... keys) This command works exactly likeSINTERbut instead of returning the result set, it returns just the cardinality of the result.longsintercard(int limit, byte[]... keys) This command works exactly likeSINTERbut instead of returning the result set, it returns just the cardinality of the result.longsintercard(int limit, String... keys) This command works exactly likeSINTERbut instead of returning the result set, it returns just the cardinality of the result.longsintercard(String... keys) This command works exactly likeSINTERbut instead of returning the result set, it returns just the cardinality of the result.longsinterstore(byte[] dstkey, byte[]... keys) This command works exactly likeSINTERbut instead of being returned the resulting set is stored as dstkey.longsinterstore(String dstkey, String... keys) This command works exactly likeSINTERbut instead of being returned the resulting set is stored as dstkey.booleansismember(byte[] key, byte[] member) Return true if member is a member of the set stored at key, otherwise false is returned.booleanReturn true if member is a member of the set stored at key, otherwise false is returned.Deprecated.Deprecated.UsereplicaofNoOne().slowlogGet(long entries) slowlogGetBinary(long entries) longSet<byte[]> smembers(byte[] key) Return all the members (elements) of the set value stored at key.Return all the members (elements) of the set value stored at key.smismember(byte[] key, byte[]... members) Returns whether each member is a member of the set stored at key.smismember(String key, String... members) Returns whether each member is a member of the set stored at key.longsmove(byte[] srckey, byte[] dstkey, byte[] member) Move the specified member from the set at srckey to the set at dstkey.longMove the specified member from the set at srckey to the set at dstkey.List<byte[]> sort(byte[] key) Sort a Set or a List.longsort(byte[] key, byte[] dstkey) Sort a Set or a List and Store the Result at dstkey.List<byte[]> sort(byte[] key, SortingParams sortingParams) Sort a Set or a List accordingly to the specified parameters.longsort(byte[] key, SortingParams sortingParams, byte[] dstkey) Sort a Set or a List accordingly to the specified parameters and store the result at dstkey.Sort a Set or a List.longSort a Set or a List and Store the Result at dstkey.sort(String key, SortingParams sortingParams) Sort a Set or a List accordingly to the specified parameters.longsort(String key, SortingParams sortingParams, String dstkey) Sort a Set or a List accordingly to the specified parameters and store the result at dstkey.List<byte[]> sortReadonly(byte[] key, SortingParams sortingParams) sortReadonly(String key, SortingParams sortingParams) Read-only variant of theSORTcommand.byte[]spop(byte[] key) Remove a random element from a Set returning it as return value.Set<byte[]> spop(byte[] key, long count) Remove a random element from a Set returning it as return value.By default, the commandSetCommands.spop(String)pops a single member from the set.byte[]srandmember(byte[] key) Return a random element from a Set, without removing the element.List<byte[]> srandmember(byte[] key, int count) srandmember(String key) Return a random element from a Set, without removing the element.srandmember(String key, int count) Return a random elements from a Set, without removing the elements.longsrem(byte[] key, byte[]... members) Remove the specified member from the set value stored at key.longRemove 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) sscan(String key, String cursor, ScanParams params) strAlgoLCSKeys(byte[] keyA, byte[] keyB, StrAlgoLCSParams params) Deprecated.STRALGO LCS command will be removed from Redis 7.strAlgoLCSKeys(String keyA, String keyB, StrAlgoLCSParams params) Deprecated.STRALGO LCS command will be removed from Redis 7.strAlgoLCSStrings(byte[] strA, byte[] strB, StrAlgoLCSParams params) Deprecated.STRALGO LCS command will be removed from Redis 7.strAlgoLCSStrings(String strA, String strB, StrAlgoLCSParams params) Deprecated.STRALGO LCS command will be removed from Redis 7.longstrlen(byte[] key) longStrLen Command Return the length of the string value stored at key.voidsubscribe(BinaryJedisPubSub jedisPubSub, byte[]... channels) voidsubscribe(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).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.Return the members of a set resulting from the union of all the sets hold at the specified keys.longsunionstore(byte[] dstkey, byte[]... keys) This command works exactly likeSUNIONbut instead of being returned the resulting set is stored as dstkey.longsunionstore(String dstkey, String... keys) This command works exactly likeSUNIONbut instead of being returned the resulting set is stored as dstkey.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.time()toString()longtouch(byte[] key) longtouch(byte[]... keys) Alters the last access time of a key(s).longTouch Command Alters the last access time of a key.longAlters the last access time of a key(s).longttl(byte[] key) The TTL command returns the remaining time to live in seconds of a key that has anEXPIREset.longThe TTL command returns the remaining time to live in seconds of a key that has anEXPIREset.type(byte[] key) Return the type of the value stored at key in form of a string.Return the type of the value stored at key in form of a string.longunlink(byte[] key) longunlink(byte[]... keys) This command is very similar to DEL: it removes the specified keys.longUnlink Command This command is very similar toDEL: it removes the specified key.longThis command is very similar to DEL: it removes the specified keys.unwatch()waitAOF(long numLocal, long numReplicas, long timeout) Blocks the current client until all the previous write commands are acknowledged as having been fsynced to the AOF of the local Redis and/or at least the specified number of replicas.longwaitReplicas(int replicas, long timeout) Synchronous replication of Redis as described here: http://antirez.com/news/66.watch(byte[]... keys) longxack(byte[] key, byte[] group, byte[]... ids) longxack(String key, String group, StreamEntryID... ids) XACK key group ID [ID ...]byte[]xadd(byte[] key, XAddParams params, Map<byte[], byte[]> hash) XADD key ID field string [field string ...]xautoclaim(byte[] key, byte[] groupName, byte[] consumerName, long minIdleTime, byte[] start, XAutoClaimParams params) xautoclaim(String key, String group, String consumerName, long minIdleTime, StreamEntryID start, XAutoClaimParams params) XAUTOCLAIM key group consumer min-idle-time start [COUNT count]xautoclaimJustId(byte[] key, byte[] groupName, byte[] consumerName, long minIdleTime, byte[] start, XAutoClaimParams params) xautoclaimJustId(String key, String group, String consumerName, long minIdleTime, StreamEntryID start, XAutoClaimParams params) XAUTOCLAIM key group consumer min-idle-time start [COUNT count] JUSTIDList<byte[]> xclaim(byte[] key, byte[] group, byte[] consumerName, long minIdleTime, XClaimParams params, byte[]... ids) xclaim(String key, String group, String consumerName, long minIdleTime, XClaimParams params, StreamEntryID... ids) XCLAIM key group consumer min-idle-time <ID-1> ... <ID-N> [IDLE <milliseconds>] [TIME <mstime>] [RETRYCOUNT <count>] [FORCE]List<byte[]> xclaimJustId(byte[] key, byte[] group, byte[] consumerName, long minIdleTime, XClaimParams params, byte[]... ids) xclaimJustId(String key, String group, String consumerName, long minIdleTime, XClaimParams params, StreamEntryID... ids) XCLAIM key group consumer min-idle-time <ID-1> ... <ID-N> [IDLE <milliseconds>] [TIME <mstime>] [RETRYCOUNT <count>] [FORCE] JUSTIDlongxdel(byte[] key, byte[]... ids) longxdel(String key, StreamEntryID... ids) XDEL key ID [ID ...]xgroupCreate(byte[] key, byte[] consumer, byte[] id, boolean makeStream) xgroupCreate(String key, String groupName, StreamEntryID id, boolean makeStream) XGROUP CREATE key groupName <id or $>booleanxgroupCreateConsumer(byte[] key, byte[] groupName, byte[] consumerName) booleanxgroupCreateConsumer(String key, String groupName, String consumerName) XGROUP CREATECONSUMER key groupName consumerNamelongxgroupDelConsumer(byte[] key, byte[] groupName, byte[] consumerName) longxgroupDelConsumer(String key, String groupName, String consumerName) XGROUP DELCONSUMER key groupName consumerNamelongxgroupDestroy(byte[] key, byte[] consumer) longxgroupDestroy(String key, String groupName) XGROUP DESTROY key groupNamexgroupSetID(byte[] key, byte[] consumer, byte[] id) xgroupSetID(String key, String groupName, StreamEntryID id) XGROUP SETID key groupName <id or $>xinfoConsumers(byte[] key, byte[] group) xinfoConsumers(String key, String group) Introspection command used in order to retrieve different information about consumers in the groupxinfoGroup(byte[] key) Deprecated.xinfoGroup(String key) Deprecated.xinfoGroups(byte[] key) xinfoGroups(String key) Introspection command used in order to retrieve different information about groups in the streamxinfoStream(byte[] key) xinfoStream(String key) Introspection command used in order to retrieve different information about the streamxinfoStreamFull(byte[] key) Introspection command used in order to retrieve all information about the streamxinfoStreamFull(byte[] key, int count) Introspection command used in order to retrieve all information about the streamxinfoStreamFull(String key) Introspection command used in order to retrieve all information about the streamxinfoStreamFull(String key, int count) Introspection command used in order to retrieve all information about the streamlongxlen(byte[] key) longXLEN keyxpending(byte[] key, byte[] groupName) xpending(byte[] key, byte[] groupName, byte[] start, byte[] end, int count, byte[] consumerName) Deprecated.xpending(byte[] key, byte[] groupName, XPendingParams params) XPENDING key groupxpending(String key, String groupName, XPendingParams params) XPENDING key group [[IDLE min-idle-time] start end count [consumer]]xpending(String key, String groupName, StreamEntryID start, StreamEntryID end, int count, String consumerName) xrange(byte[] key, byte[] start, byte[] end) xrange(byte[] key, byte[] start, byte[] end, int count) xrange(String key, StreamEntryID start, StreamEntryID end) XRANGE key start endxrange(String key, StreamEntryID start, StreamEntryID end, int count) XRANGE key start end COUNT countxread(XReadParams xReadParams, Map.Entry<byte[], byte[]>... streams) xread(XReadParams xReadParams, Map<String, StreamEntryID> streams) XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]xreadGroup(byte[] groupName, byte[] consumer, XReadGroupParams xReadGroupParams, Map.Entry<byte[], byte[]>... streams) xreadGroup(String groupName, String consumer, XReadGroupParams xReadGroupParams, Map<String, StreamEntryID> streams) XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]xrevrange(byte[] key, byte[] end, byte[] start) xrevrange(byte[] key, byte[] end, byte[] start, int count) xrevrange(String key, StreamEntryID end, StreamEntryID start) XREVRANGE key end startxrevrange(String key, StreamEntryID end, StreamEntryID start, int count) XREVRANGE key end start COUNT countlongxtrim(byte[] key, long maxLen, boolean approximateLength) longxtrim(byte[] key, XTrimParams params) longXTRIM key MAXLEN [~] countlongxtrim(String key, XTrimParams params) XTRIM key MAXLEN|MINID [=|~] threshold [LIMIT count]longzadd(byte[] key, double score, byte[] member) Add the specified member having the specified score to the sorted set stored at key.longzadd(byte[] key, double score, byte[] member, ZAddParams params) longlongzadd(byte[] key, Map<byte[], Double> scoreMembers, ZAddParams params) longAdd the specified member having the specified score to the sorted set stored at key.longzadd(String key, double score, String member, ZAddParams params) Similar toZADDbut can be used with optional params.longSimilar toZADDbut for multiple members.longSimilar toZADDbut can be used with optional params, and fits for multiple members.zaddIncr(byte[] key, double score, byte[] member, ZAddParams params) zaddIncr(String key, double score, String member, ZAddParams params) Increments the score of member in the sorted set stored at key by increment.longzcard(byte[] key) Return the sorted set cardinality (number of elements).longReturn the sorted set cardinality (number of elements).longzcount(byte[] key, byte[] min, byte[] max) longzcount(byte[] key, double min, double max) longReturn the number of elements in the sorted set at key with a score between min and max.longSimilar toZCOUNTbut with exclusive range.Set<byte[]> zdiff(byte[]... keys) Compute the difference between all the sets in the given keys.longzdiffStore(byte[] dstkey, byte[]... keys) longzdiffStore(String dstkey, String... keys) Compute the difference between all the sets in the given keys.zdiffWithScores(byte[]... keys) zdiffWithScores(String... keys) Compute the difference between all the sets in the given keys.doublezincrby(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.zincrby(byte[] key, double increment, byte[] member, ZIncrByParams params) doubleIf 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.zincrby(String key, double increment, String member, ZIncrByParams params) Similar toZINCRBYbut can be used with optionals params.Set<byte[]> Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the connection.Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the connection.longzintercard(byte[]... keys) Similar toZINTER, but instead of returning the result set, it returns just the cardinality of the result.longzintercard(long limit, byte[]... keys) Similar toZINTER, but instead of returning the result set, it returns just the cardinality of the result.longzintercard(long limit, String... keys) Similar toZINTER, but instead of returning the result set, it returns just the cardinality of the result.longzintercard(String... keys) Similar toZINTER, but instead of returning the result set, it returns just the cardinality of the result.longzinterstore(byte[] dstkey, byte[]... sets) Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey.longzinterstore(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.longzinterstore(String dstkey, String... sets) Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey.longzinterstore(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.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.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.longzlexcount(byte[] key, byte[] min, byte[] max) longReturn the number of elements in the sorted set at key with a value between min and max, when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.zmpop(SortedSetOption option, byte[]... keys) zmpop(SortedSetOption option, int count, byte[]... keys) zmpop(SortedSetOption option, int count, String... keys) zmpop(SortedSetOption option, String... keys) zmscore(byte[] key, byte[]... members) Returns the scores associated with the specified members in the sorted set stored at key.Returns the scores associated with the specified members in the sorted set stored at key.zpopmax(byte[] key) zpopmax(byte[] key, int count) Remove and return the member with the highest score in the sorted set stored at key.Remove and return up to count members with the highest scores in the sorted set stored at key.zpopmin(byte[] key) zpopmin(byte[] key, int count) Remove and return the member with the lowest score in the sorted set stored at key.Remove and return up to count members with the lowest scores in the sorted set stored at key.byte[]zrandmember(byte[] key) List<byte[]> zrandmember(byte[] key, long count) zrandmember(String key) Return a random element from the sorted set value stored at key.zrandmember(String key, long count) Return an array of distinct elements.zrandmemberWithScores(byte[] key, long count) zrandmemberWithScores(String key, long count) Similar toZRANDMEMBERbut the replay will include the scores with the result.List<byte[]> zrange(byte[] key, long start, long stop) List<byte[]> zrange(byte[] key, ZRangeParams zRangeParams) Returns the specified range of elements in the sorted set stored at key.zrange(String key, ZRangeParams zRangeParams) Similar toZRANGEbut can be used with additional params.List<byte[]> zrangeByLex(byte[] key, byte[] min, byte[] max) List<byte[]> zrangeByLex(byte[] key, byte[] min, byte[] max, int offset, int count) zrangeByLex(String key, String min, String max) Return all the elements in the sorted set at key with a value between min and max, when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.zrangeByLex(String key, String min, String max, int offset, int count) Similar toZRANGEbut with limit option.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).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).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).zrangeByScore(String key, String min, String max) Similar toZRANGEbut with exclusive range.zrangeByScore(String key, String min, String max, int offset, int count) Similar toZRANGEbut with limit option,zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max) zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max, int offset, int count) 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).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).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).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).zrangeByScoreWithScores(String key, String min, String max) Similar toZRANGEbut with exclusive range, and return with scores.zrangeByScoreWithScores(String key, String min, String max, int offset, int count) Similar toZRANGEbut with exclusive range, with limit options and return with scores.longzrangestore(byte[] dest, byte[] src, ZRangeParams zRangeParams) longzrangestore(String dest, String src, ZRangeParams zRangeParams) Similar toZRANGEbut stores the result indest.zrangeWithScores(byte[] key, long start, long stop) zrangeWithScores(byte[] key, ZRangeParams zRangeParams) zrangeWithScores(String key, long start, long stop) Returns the specified range of elements in the sorted set stored at key with the scores.zrangeWithScores(String key, ZRangeParams zRangeParams) Similar toZRANGEbut can be used with additional params.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.Return the rank (or index) of member in the sorted set at key, with scores being ordered from low to high.zrankWithScore(byte[] key, byte[] member) Returns the rank and the score of member in the sorted set stored at key, with the scores ordered from low to high.zrankWithScore(String key, String member) Returns the rank and the score of member in the sorted set stored at key, with the scores ordered from low to high.longzrem(byte[] key, byte[]... members) Remove the specified member from the sorted set value stored at key.longRemove the specified member from the sorted set value stored at key.longzremrangeByLex(byte[] key, byte[] min, byte[] max) longzremrangeByLex(String key, String min, String max) Remove all elements in the sorted set stored at key between the lexicographical range specified by min and max, when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.longzremrangeByRank(byte[] key, long start, long stop) Remove all elements in the sorted set at key with rank between start and end.longzremrangeByRank(String key, long start, long stop) Remove all elements in the sorted set at key with rank between start and end.longzremrangeByScore(byte[] key, byte[] min, byte[] max) longzremrangeByScore(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).longzremrangeByScore(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).longzremrangeByScore(String key, String min, String max) Similar toZREMRANGEbut with limit option.List<byte[]> zrevrange(byte[] key, long start, long stop) Returns the specified range of elements in the sorted set stored at key.List<byte[]> zrevrangeByLex(byte[] key, byte[] max, byte[] min) List<byte[]> zrevrangeByLex(byte[] key, byte[] max, byte[] min, int offset, int count) zrevrangeByLex(String key, String max, String min) Return all the elements in the sorted set at key with a value between max and min, when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.zrevrangeByLex(String key, String max, String min, int offset, int count) Similar toZRANGEbut with limit option.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) zrevrangeByScore(String key, double max, double min) Return all the elements in the sorted set at key with a score between max and min (including elements with score equal to max or min).zrevrangeByScore(String key, double max, double min, int offset, int count) Similar toZRANGEbut with limit option,zrevrangeByScore(String key, String max, String min) Similar toZREVRANGEbut with exclusive range.zrevrangeByScore(String key, String max, String min, int offset, int count) Similar toZREVRANGEbut with limit option,zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min) zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min, int offset, int count) zrevrangeByScoreWithScores(byte[] key, double max, double min) zrevrangeByScoreWithScores(byte[] key, double max, double min, int offset, int count) zrevrangeByScoreWithScores(String key, double max, double min) Similar toZREVRANGEbut return with scores.zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) Similar toZREVRANGEbut with limit options and return with scores.zrevrangeByScoreWithScores(String key, String max, String min) Similar toZREVRANGEbut with exclusive range, and return with scores.zrevrangeByScoreWithScores(String key, String max, String min, int offset, int count) Similar toZREVRANGEbut with exclusive range, with limit options and return with scores.zrevrangeWithScores(byte[] key, long start, long stop) zrevrangeWithScores(String key, long start, long stop) Similar toZREVRANGEbut the reply will include the scores of the returned elements.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.Return the rank (or index) of member in the sorted set at key, with scores being ordered from high to low.zrevrankWithScore(byte[] key, byte[] member) Returns the rank and the score of member in the sorted set stored at key, with the scores ordered from high to low.zrevrankWithScore(String key, String member) Returns the rank and the score of member in the sorted set stored at key, with the scores ordered from high to low.zscan(byte[] key, byte[] cursor) zscan(byte[] key, byte[] cursor, ScanParams params) zscan(String key, String cursor, ScanParams params) zscore(byte[] key, byte[] member) Return the score of the specified element of the sorted set at key.Return the score of the specified element of the sorted set at key.Set<byte[]> Add multiple sorted sets, This command is similar to ZUNIONSTORE, but instead of storing the resulting sorted set, it is returned to the connection.Add multiple sorted sets, This command is similar to ZUNIONSTORE, but instead of storing the resulting sorted set, it is returned to the connection.longzunionstore(byte[] dstkey, byte[]... sets) Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey.longzunionstore(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.longzunionstore(String dstkey, String... sets) Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey.longzunionstore(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.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.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface redis.clients.jedis.commands.HashCommands
hscanMethods inherited from interface redis.clients.jedis.commands.SetCommands
sscanMethods inherited from interface redis.clients.jedis.commands.SortedSetCommands
zscanMethods inherited from interface redis.clients.jedis.commands.StreamBinaryCommands
xaddMethods inherited from interface redis.clients.jedis.commands.StreamCommands
xadd
-
Field Details
-
connection
-
commandObjects
-
db
private int db -
transaction
-
isInMulti
private boolean isInMulti -
isInWatch
private boolean isInWatch -
pipeline
-
DUMMY_ARRAY
protected static final byte[][] DUMMY_ARRAY -
dataSource
-
-
Constructor Details
-
Jedis
public Jedis() -
Jedis
This constructor only accepts a URI string.JedisURIHelper.isValid(java.net.URI)can be used before this.- Parameters:
url-
-
Jedis
-
Jedis
-
Jedis
-
Jedis
-
Jedis
-
Jedis
public Jedis(String host, int port, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) -
Jedis
-
Jedis
-
Jedis
public Jedis(String host, int port, int timeout, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) -
Jedis
-
Jedis
-
Jedis
-
Jedis
public Jedis(String host, int port, int connectionTimeout, int soTimeout, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) -
Jedis
public Jedis(String host, int port, int connectionTimeout, int soTimeout, int infiniteSoTimeout, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) -
Jedis
-
Jedis
public Jedis(URI uri, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) -
Jedis
-
Jedis
public Jedis(URI uri, int timeout, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) -
Jedis
-
Jedis
public Jedis(URI uri, int connectionTimeout, int soTimeout, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) -
Jedis
public Jedis(URI uri, int connectionTimeout, int soTimeout, int infiniteSoTimeout, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) -
Jedis
-
Jedis
-
Jedis
-
Jedis
-
-
Method Details
-
toString
-
getClient
-
getConnection
-
connect
public void connect() -
disconnect
public void disconnect()Closing the socket will disconnect the server connection. -
isConnected
public boolean isConnected() -
isBroken
public boolean isBroken() -
resetState
public void resetState() -
setDataSource
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
multi
-
pipelined
-
checkIsInMultiOrPipeline
protected void checkIsInMultiOrPipeline() -
getDB
public int getDB() -
ping
Description copied from interface:ServerCommandsThis command is often used to test if a connection is still alive, or to measure latency.- Specified by:
pingin interfaceServerCommands- Returns:
PONG
-
ping
public byte[] ping(byte[] message) Works same asping()but returns argument message instead ofPONG.- Parameters:
message-- Returns:
- message
-
select
Select the DB with having the specified zero-based numeric index. For default every new connection connection is automatically selected to DB 0.- Specified by:
selectin interfaceDatabaseCommands- Parameters:
index-- Returns:
- OK
-
swapDB
Description copied from interface:DatabaseCommandsThis 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.- Specified by:
swapDBin interfaceDatabaseCommands- Parameters:
index1-index2-- Returns:
- OK
-
flushDB
Delete all the keys of the currently selected DB. This command never fails.- Specified by:
flushDBin interfaceDatabaseCommands- Specified by:
flushDBin interfaceServerCommands- Returns:
- OK
-
flushDB
Delete all the keys of the currently selected DB. This command never fails.- Specified by:
flushDBin interfaceDatabaseCommands- Specified by:
flushDBin interfaceServerCommands- Parameters:
flushMode-- Returns:
- OK
-
flushAll
Delete all the keys of all the existing databases, not just the currently selected one. This command never fails.- Specified by:
flushAllin interfaceServerCommands- Returns:
- OK
-
flushAll
Delete all the keys of all the existing databases, not just the currently selected one. This command never fails.- Specified by:
flushAllin interfaceServerCommands- Parameters:
flushMode-- Returns:
- OK
-
quit
Deprecated.The QUIT command is deprecated, see #11420.disconnect()can be used instead.Ask the server to silently close the connection.- Specified by:
quitin interfaceServerCommands- Returns:
- OK
-
copy
public boolean copy(byte[] srcKey, byte[] dstKey, int db, boolean replace) COPY source destination [DB destination-db] [REPLACE]- Specified by:
copyin interfaceDatabaseCommands- Parameters:
srcKey- the source key.dstKey- the destination key.db-replace-- See Also:
-
copy
public boolean copy(byte[] srcKey, byte[] dstKey, boolean replace) COPY source destination [DB destination-db] [REPLACE]- Specified by:
copyin interfaceKeyBinaryCommands- Parameters:
srcKey- the source key.dstKey- the destination key.replace-
-
set
Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1 GB).Time complexity: O(1)
- Specified by:
setin interfaceStringBinaryCommands- Parameters:
key-value-- Returns:
- OK
-
set
Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1 GB).- Specified by:
setin interfaceStringBinaryCommands- Parameters:
key-value-params- NX|XX, NX -- Only set the key if it does not already exist. XX -- Only set the key if it already exists. EX|PX, expire time units: EX = seconds; PX = milliseconds- Returns:
- simple-string-reply
OKifSETwas executed correctly, ornullif theSEToperation was not performed because the user specified the NX or XX option but the condition was not met.
-
get
public byte[] get(byte[] key) Get the value of the specified key. If the key does not exist the special value 'nil' is returned. If the value stored at key is not a string an error is returned because GET can only handle string values.Time complexity: O(1)
- Specified by:
getin interfaceStringBinaryCommands- Parameters:
key-- Returns:
- Bulk reply
-
setGet
Description copied from interface:StringBinaryCommandsWARNING:SetParams.get()MUST NOT be used with this method.- Specified by:
setGetin interfaceStringBinaryCommands
-
getDel
public byte[] getDel(byte[] key) Get the value of key and delete the key. This command is similar to GET, except for the fact that it also deletes the key on success (if and only if the key's value type is a string).Time complexity: O(1)
- Specified by:
getDelin interfaceStringBinaryCommands- Parameters:
key-- Returns:
- The value of key
-
getEx
- Specified by:
getExin interfaceStringBinaryCommands
-
exists
public long exists(byte[]... keys) Test if the specified keys exist. The command returns the number of keys exist. Time complexity: O(N)- Specified by:
existsin interfaceKeyBinaryCommands- Parameters:
keys-- Returns:
- An integer greater than 0 if one or more keys exist, 0 if none of the specified keys exist
-
exists
public boolean exists(byte[] key) Test if the specified key exists. The command returns true if the key exists, otherwise false is returned. Note that even keys set with an empty string as value will return true. Time complexity: O(1)- Specified by:
existsin interfaceKeyBinaryCommands- Parameters:
key-- Returns:
trueif the key exists, otherwisefalse
-
del
public long del(byte[]... keys) Remove the specified keys. If a given key does not exist no operation is performed for this key. The command returns the number of keys removed. Time complexity: O(1)- Specified by:
delin interfaceKeyBinaryCommands- Parameters:
keys-- Returns:
- The number of keys that were removed
-
del
public long del(byte[] key) - Specified by:
delin interfaceKeyBinaryCommands
-
unlink
public long unlink(byte[]... keys) This command is very similar to DEL: it removes the specified keys. Just like DEL a key is ignored if it does not exist. However the command performs the actual memory reclaiming in a different thread, so it is not blocking, while DEL is. This is where the command name comes from: the command just unlinks the keys from the keyspace. The actual removal will happen later asynchronously.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.
- Specified by:
unlinkin interfaceKeyBinaryCommands- Parameters:
keys-- Returns:
- The number of keys that were unlinked
-
unlink
public long unlink(byte[] key) - Specified by:
unlinkin interfaceKeyBinaryCommands
-
type
Return the type of the value stored at key in form of a string. The type can be one of "none", "string", "list", "set". "none" is returned if the key does not exist. Time complexity: O(1)- Specified by:
typein interfaceKeyBinaryCommands- Parameters:
key-- Returns:
- "none" if the key does not exist, "string" if the key contains a String value, "list" if the key contains a List value, "set" if the key contains a Set value, "zset" if the key contains a Sorted Set value, "hash" if the key contains a Hash value
-
keys
Returns all the keys matching the glob-style pattern as space separated strings. For example if you have in the database the keys "foo" and "foobar" the command "KEYS foo*" will return "foo foobar".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:
- h?llo will match hello hallo hhllo
- h*llo will match hllo heeeello
- h[ae]llo will match hello and hallo, but not hillo
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)
- Specified by:
keysin interfaceKeyBinaryCommands- Parameters:
pattern-- Returns:
- Multi bulk reply
-
randomBinaryKey
public byte[] randomBinaryKey()Return a randomly selected key from the currently selected DB.Time complexity: O(1)
- Specified by:
randomBinaryKeyin interfaceKeyBinaryCommands- Returns:
- The randomly selected key or an empty string is the database is empty
-
rename
Atomically renames the key oldkey to newkey. If the source and destination name are the same an error is returned. If newkey already exists it is overwritten.Time complexity: O(1)
- Specified by:
renamein interfaceKeyBinaryCommands- Parameters:
oldkey-newkey-- Returns:
- OK
-
renamenx
public long renamenx(byte[] oldkey, byte[] newkey) Rename oldkey into newkey but fails if the destination key newkey already exists.Time complexity: O(1)
- Specified by:
renamenxin interfaceKeyBinaryCommands- Parameters:
oldkey-newkey-- Returns:
- 1 if the key was renamed 0 if the target key already exist
-
dbSize
public long dbSize()Return the number of keys in the currently selected database.- Specified by:
dbSizein interfaceDatabaseCommands- Returns:
- The number of keys
-
expire
public long expire(byte[] key, long seconds) Set a timeout on the specified key. After the timeout the key will be automatically deleted by the server. A key with an associated timeout is said to be volatile in Redis terminology.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
PERSISTcommand.Time complexity: O(1)
- Specified by:
expirein interfaceKeyBinaryCommands- Parameters:
key-seconds-- Returns:
- 1: the timeout was set. 0: the timeout was not set.
- See Also:
-
expire
- Specified by:
expirein interfaceKeyBinaryCommands
-
pexpire
public long pexpire(byte[] key, long milliseconds) Set a timeout on the specified key. After the timeout the key will be automatically deleted by the server. A key with an associated timeout is said to be volatile in Redis terminology.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
PERSISTcommand.Time complexity: O(1)
- Specified by:
pexpirein interfaceKeyBinaryCommands- Parameters:
key-milliseconds-- Returns:
- 1: the timeout was set. 0: the timeout was not set.
- See Also:
-
pexpire
- Specified by:
pexpirein interfaceKeyBinaryCommands
-
expireTime
public long expireTime(byte[] key) - Specified by:
expireTimein interfaceKeyBinaryCommands
-
pexpireTime
public long pexpireTime(byte[] key) - Specified by:
pexpireTimein interfaceKeyBinaryCommands
-
expireAt
public long expireAt(byte[] key, long unixTime) EXPIREAT works exactly likeEXPIREbut 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
PERSISTcommand.Time complexity: O(1)
- Specified by:
expireAtin interfaceKeyBinaryCommands- Parameters:
key-unixTime-- Returns:
- 1: the timeout was set. 0: the timeout was not set since the key already has an associated timeout (this may happen only in Redis versions < 2.1.3, Redis >= 2.1.3 will happily update the timeout), or the key does not exist.
- See Also:
-
expireAt
- Specified by:
expireAtin interfaceKeyBinaryCommands
-
pexpireAt
public long pexpireAt(byte[] key, long millisecondsTimestamp) - Specified by:
pexpireAtin interfaceKeyBinaryCommands
-
pexpireAt
- Specified by:
pexpireAtin interfaceKeyBinaryCommands
-
ttl
public long ttl(byte[] key) The TTL command returns the remaining time to live in seconds of a key that has anEXPIREset. This introspection capability allows a Redis connection to check how many seconds a given key will continue to be part of the dataset.- Specified by:
ttlin interfaceKeyBinaryCommands- Parameters:
key-- Returns:
- TTL in seconds, or a negative value in order to signal an error
-
touch
public long touch(byte[]... keys) Alters the last access time of a key(s). A key is ignored if it does not exist. Time complexity: O(N) where N is the number of keys that will be touched.- Specified by:
touchin interfaceKeyBinaryCommands- Parameters:
keys-- Returns:
- The number of keys that were touched.
-
touch
public long touch(byte[] key) - Specified by:
touchin interfaceKeyBinaryCommands
-
move
public long move(byte[] key, int dbIndex) Move the specified key from the currently selected DB to the specified destination DB. Note that this command returns 1 only if the key was successfully moved, and 0 if the target key was already there or if the source key was not found at all, so it is possible to use MOVE as a locking primitive.- Specified by:
movein interfaceDatabaseCommands- Parameters:
key-dbIndex-- Returns:
- 1 if the key was moved 0 if the key was not moved because already present on the target DB or was not found in the current DB.
- See Also:
-
getSet
public byte[] getSet(byte[] key, byte[] value) GETSET is an atomic set this value and return the old value command. Set key to the string value and return the old value stored at key. The string can't be longer than 1073741824 bytes (1 GB).Time complexity: O(1)
- Specified by:
getSetin interfaceStringBinaryCommands- Parameters:
key-value-- Returns:
- Bulk reply
-
mget
Get the values of all the specified keys. If one or more keys don't exist or is not of type String, a 'nil' value is returned instead of the value of the specified key, but the operation never fails.Time complexity: O(1) for every key
- Specified by:
mgetin interfaceStringBinaryCommands- Parameters:
keys-- Returns:
- Multi bulk reply
-
setnx
public long setnx(byte[] key, byte[] value) SETNX works exactly likeSETwith the only difference that if the key already exists no operation is performed. SETNX actually means "SET if Not eXists".Time complexity: O(1)
- Specified by:
setnxin interfaceStringBinaryCommands- Parameters:
key-value-- Returns:
- 1 if the key was set 0 if the key was not set
-
setex
The command is exactly equivalent to the following group of commands:SET+EXPIRE. The operation is atomic.Time complexity: O(1)
- Specified by:
setexin interfaceStringBinaryCommands- Parameters:
key-seconds-value-- Returns:
- OK
-
mset
Set the the respective keys to the respective values. MSET will replace old values with new values, whileMSETNXwill 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.
- Specified by:
msetin interfaceStringBinaryCommands- Parameters:
keysvalues-- Returns:
- OK
- See Also:
-
msetnx
public long msetnx(byte[]... keysvalues) Set the respective keys to the respective values.MSETwill 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.
- Specified by:
msetnxin interfaceStringBinaryCommands- Parameters:
keysvalues-- Returns:
- 1 if the all the keys were set 0 if no key was set (at least one key already existed)
- See Also:
-
decrBy
public long decrBy(byte[] key, long decrement) DECRBY work just likeDECRbut instead to decrement by 1 the decrement is integer.DECR 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)
- Specified by:
decrByin interfaceStringBinaryCommands- Parameters:
key-decrement-- Returns:
- The value of key after the decrement
- See Also:
-
decr
public long decr(byte[] key) Decrement the number stored at key by one. If the key does not exist or contains a value of a wrong type, set the key to the value of "0" before to perform the decrement operation.DECR 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)
- Specified by:
decrin interfaceStringBinaryCommands- Parameters:
key-- Returns:
- The value of key after the decrement
- See Also:
-
incrBy
public long incrBy(byte[] key, long increment) INCRBY work just likeINCRbut 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)
- Specified by:
incrByin interfaceStringBinaryCommands- Parameters:
key-increment-- Returns:
- The value of key after the increment
- See Also:
-
incrByFloat
public double incrByFloat(byte[] key, double increment) INCRBYFLOAT work just likeincrBy(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)
- Specified by:
incrByFloatin interfaceStringBinaryCommands- Parameters:
key- the key to incrementincrement- the value to increment by- Returns:
- The value of key after the increment
- See Also:
-
incr
public long incr(byte[] key) Increment the number stored at key by one. If the key does not exist or contains a value of a wrong type, set the key to the value of "0" before to perform the increment operation.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)
- Specified by:
incrin interfaceStringBinaryCommands- Parameters:
key-- Returns:
- The value of key after the increment
- See Also:
-
append
public 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. If the key does not exist it is created and set as an empty string, so APPEND will be very similar to SET in this special case.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.
- Specified by:
appendin interfaceStringBinaryCommands- Parameters:
key-value-- Returns:
- The total length of the string after the append operation
-
substr
public byte[] substr(byte[] key, int start, int end) Return a subset of the string from offset start to offset end (both offsets are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the string. So -1 means the last char, -2 the penultimate and so forth.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.
- Specified by:
substrin interfaceStringBinaryCommands- Parameters:
key-start-end-- Returns:
- Bulk reply
-
hset
public long hset(byte[] key, byte[] field, byte[] value) Set the specified hash field to the specified value.If key does not exist, a new key holding a hash is created.
Time complexity: O(1)
- Specified by:
hsetin interfaceHashBinaryCommands- Parameters:
key-field-value-- Returns:
- If the field already exists, and the HSET just produced an update of the value, 0 is returned, otherwise if a new field is created 1 is returned.
-
hset
- Specified by:
hsetin interfaceHashBinaryCommands
-
hget
public byte[] hget(byte[] key, byte[] field) If key holds a hash, retrieve the value associated to the specified field.If the field is not found or the key does not exist, a special 'nil' value is returned.
Time complexity: O(1)
- Specified by:
hgetin interfaceHashBinaryCommands- Parameters:
key-field-- Returns:
- Bulk reply
-
hsetnx
public long hsetnx(byte[] key, byte[] field, byte[] value) Set the specified hash field to the specified value if the field not exists. Time complexity: O(1)- Specified by:
hsetnxin interfaceHashBinaryCommands- Parameters:
key-field-value-- Returns:
- If the field already exists, 0 is returned, otherwise if a new field is created 1 is returned.
-
hmset
Set the respective fields to the respective values. HMSET replaces old values with new values.If key does not exist, a new key holding a hash is created.
Time complexity: O(N) (with N being the number of fields)
- Specified by:
hmsetin interfaceHashBinaryCommands- Parameters:
key-hash-- Returns:
- OK
-
hmget
Retrieve the values associated to the specified 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)
- Specified by:
hmgetin interfaceHashBinaryCommands- Parameters:
key-fields-- Returns:
- A list of all the values associated with the specified fields, in the same order of the request
-
hincrBy
public long hincrBy(byte[] key, byte[] field, long value) Increment the number stored at field in the hash at key by value. If key does not exist, a new key holding a hash is created. If field does not exist or holds a string, the value is set to 0 before applying the operation. Since the value argument is signed you can use this command to perform both increments and decrements.The range of values supported by HINCRBY is limited to 64 bit signed integers.
Time complexity: O(1)
- Specified by:
hincrByin interfaceHashBinaryCommands- Parameters:
key-field-value-- Returns:
- The value of key after the increment
-
hincrByFloat
public 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. If key does not exist, a new key holding a hash is created. If field does not exist or holds a string, the value is set to 0 before applying the operation. Since the value argument is signed you can use this command to perform both increments and decrements.The range of values supported by HINCRBYFLOAT is limited to double precision floating point values.
Time complexity: O(1)
- Specified by:
hincrByFloatin interfaceHashBinaryCommands- Parameters:
key-field-value-- Returns:
- The new value at field after the increment operation
-
hexists
public boolean hexists(byte[] key, byte[] field) Test for existence of a specified field in a hash. Time complexity: O(1)- Specified by:
hexistsin interfaceHashBinaryCommands- Parameters:
key-field-- Returns:
trueif the hash stored at key contains the specified field,falseif the key is not found or the field is not present.
-
hdel
public long hdel(byte[] key, byte[]... fields) Remove the specified field from an hash stored at key.Time complexity: O(1)
- Specified by:
hdelin interfaceHashBinaryCommands- Parameters:
key-fields-- Returns:
- If the field was present in the hash it is deleted and 1 is returned, otherwise 0 is returned and no operation is performed.
-
hlen
public long hlen(byte[] key) Return the number of items in a hash.Time complexity: O(1)
- Specified by:
hlenin interfaceHashBinaryCommands- Parameters:
key-- Returns:
- The number of entries (fields) contained in the hash stored at key. If the specified key does not exist, 0 is returned assuming an empty hash.
-
hkeys
Return all the fields in a hash.Time complexity: O(N), where N is the total number of entries
- Specified by:
hkeysin interfaceHashBinaryCommands- Parameters:
key-- Returns:
- All the fields names contained into a hash.
-
hvals
Return all the values in a hash.Time complexity: O(N), where N is the total number of entries
- Specified by:
hvalsin interfaceHashBinaryCommands- Parameters:
key-- Returns:
- All the fields values contained into a hash.
-
hgetAll
Return all the fields and associated values in a hash.Time complexity: O(N), where N is the total number of entries
- Specified by:
hgetAllin interfaceHashBinaryCommands- Parameters:
key-- Returns:
- All the fields and values contained into a hash.
-
hrandfield
public byte[] hrandfield(byte[] key) Get one random field from a hash.Time complexity: O(N), where N is the number of fields returned
- Specified by:
hrandfieldin interfaceHashBinaryCommands- Parameters:
key-- Returns:
- one random field from a hash.
-
hrandfield
Get multiple random fields from a hash.Time complexity: O(N), where N is the number of fields returned
- Specified by:
hrandfieldin interfaceHashBinaryCommands- Parameters:
key-- Returns:
- Multiple random fields from a hash.
-
hrandfieldWithValues
Get one or multiple random fields with values from a hash.Time complexity: O(N), where N is the number of fields returned
- Specified by:
hrandfieldWithValuesin interfaceHashBinaryCommands- Parameters:
key-- Returns:
- One or multiple random fields with values from a hash.
-
rpush
public long rpush(byte[] key, byte[]... strings) Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key. If the key does not exist an empty list is created just before the append operation. If the key exists but is not a List an error is returned.Time complexity: O(1)
- Specified by:
rpushin interfaceListBinaryCommands- Parameters:
key-strings-- Returns:
- The number of elements inside the list after the push operation
-
lpush
public long lpush(byte[] key, byte[]... strings) Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key. If the key does not exist an empty list is created just before the append operation. If the key exists but is not a List an error is returned.Time complexity: O(1)
- Specified by:
lpushin interfaceListBinaryCommands- Parameters:
key-strings-- Returns:
- The number of elements inside the list after the push operation
-
llen
public long llen(byte[] key) Return the length of the list stored at the specified key. If the key does not exist zero is returned (the same behaviour as for empty lists). If the value stored at key is not a list an error is returned.Time complexity: O(1)
- Specified by:
llenin interfaceListBinaryCommands- Parameters:
key-- Returns:
- The length of the list
-
lrange
Return the specified elements of the list stored at the specified key. Start and end are zero-based indexes. 0 is the first element of the list (the list head), 1 the next element and so on.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)
- Specified by:
lrangein interfaceListBinaryCommands- Parameters:
key-start-stop-- Returns:
- A list of elements in the specified range
-
ltrim
Trim an existing list so that it will contain only the specified range of elements specified. Start and end are zero-based indexes. 0 is the first element of the list (the list head), 1 the next element and so on.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)
- Specified by:
ltrimin interfaceListBinaryCommands- Parameters:
key-start-stop-- Returns:
- OK
-
lindex
public byte[] lindex(byte[] key, long index) Return the specified element of the list stored at the specified key. 0 is the first element, 1 the second and so on. Negative indexes are supported, for example -1 is the last element, -2 the penultimate and so on.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)
- Specified by:
lindexin interfaceListBinaryCommands- Parameters:
key-index-- Returns:
- The requested element
-
lset
Set a new value as the element at index position of the List at key.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).
- Specified by:
lsetin interfaceListBinaryCommands- Parameters:
key-index-value-- Returns:
- OK
- See Also:
-
lrem
public long lrem(byte[] key, long count, byte[] value) Remove the first count occurrences of the value element from the list. If count is zero all the elements are removed. If count is negative elements are removed from tail to head, instead to go from head to tail that is the normal behaviour. So for example LREM with count -2 and hello as value to remove against the list (a,b,c,hello,x,hello,hello) will leave the list (a,b,c,hello,x). The number of removed elements is returned as an integer, see below for more information about the returned value. Note that non existing keys are considered like empty lists by LREM, so LREM against non existing keys will always return 0.Time complexity: O(N) (with N being the length of the list)
- Specified by:
lremin interfaceListBinaryCommands- Parameters:
key-count-value-- Returns:
- The number of removed elements if the operation succeeded
-
lpop
public byte[] lpop(byte[] key) Atomically return and remove the first (LPOP) or last (RPOP) element of the list. For example if the list contains the elements "a","b","c" LPOP will return "a" and the list will become "b","c".If the key does not exist or the list is already empty the special value 'nil' is returned.
- Specified by:
lpopin interfaceListBinaryCommands- Parameters:
key-- Returns:
- Bulk reply
- See Also:
-
lpop
- Specified by:
lpopin interfaceListBinaryCommands
-
lpos
Returns the index of the first matching element inside a redis list. If the element is found, its index (the zero-based position in the list) is returned. Otherwise, if no match is found, 'nil' is returned.Time complexity: O(N) where N is the number of elements in the list
- Specified by:
lposin interfaceListBinaryCommands- Parameters:
key-element-- Returns:
- The index of first matching element in the list. Value will be 'nil' when the element is not present in the list.
- See Also:
-
lpos
In case there are multiple matches Rank option specifies the "rank" of the element to return. A rank of 1 returns the first match, 2 to return the second match, and so forth. If list `foo` has elements ("a","b","c","1","2","3","c","c"), The function call to get the index of second occurrence of "c" will be as follows lpos("foo","c", LPosParams.lPosParams().rank(2)).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)).
- Specified by:
lposin interfaceListBinaryCommands- Parameters:
key-element-params-- Returns:
- The index of first matching element in the list. Value will be 'nil' when the element is not present in the list
- See Also:
-
lpos
Count will return list of position of all the first N matching elements. It is possible to specify 0 as the number of matches, as a way to tell the command we want all the matches found returned as an array of indexes. When count is used and no match is found, an empty list is returned.Time complexity: O(N) where N is the number of elements in the list
- Specified by:
lposin interfaceListBinaryCommands- Parameters:
key-element-params-count-- Returns:
- A list containing position of the matching elements inside the list
- See Also:
-
rpop
public byte[] rpop(byte[] key) Atomically return and remove the first (LPOP) or last (RPOP) element of the list. For example if the list contains the elements "a","b","c" LPOP will return "a" and the list will become "b","c".If the key does not exist or the list is already empty the special value 'nil' is returned.
- Specified by:
rpopin interfaceListBinaryCommands- Parameters:
key-- Returns:
- Bulk reply
- See Also:
-
rpop
- Specified by:
rpopin interfaceListBinaryCommands
-
rpoplpush
public 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. For example if the source list contains the elements "a","b","c" and the destination list contains the elements "foo","bar" after an RPOPLPUSH command the content of the two lists will be "a","b" and "c","foo","bar".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)
- Specified by:
rpoplpushin interfaceListBinaryCommands- Parameters:
srckey-dstkey-- Returns:
- Bulk reply
-
sadd
public long sadd(byte[] key, byte[]... members) Add the specified member to the set value stored at key. If member is already a member of the set no operation is performed. If key does not exist a new set with the specified member as sole member is created. If the key exists but does not hold a set value an error is returned.Time complexity O(1)
- Specified by:
saddin interfaceSetBinaryCommands- Parameters:
key-members-- Returns:
- The number of elements that were added to the set, not including all the elements already present in the set
-
smembers
Return all the members (elements) of the set value stored at key. This is just syntax glue forsinter(byte[][])SINTER}.Time complexity O(N)
- Specified by:
smembersin interfaceSetBinaryCommands- Parameters:
key- the key of the set- Returns:
- All elements of the set
-
srem
public long srem(byte[] key, byte[]... members) Remove the specified member from the set value stored at key. If member was not a member of the set no operation is performed. If key does not hold a set value an error is returned.Time complexity O(1)
- Specified by:
sremin interfaceSetBinaryCommands- Parameters:
key- the key of the setmembers- the set member to remove- Returns:
- The number of members that were removed from the set, not including non-existing members
-
spop
public byte[] spop(byte[] key) Remove a random element from a Set returning it as return value. If the Set is empty or the key does not exist, a nil object is returned.The
srandmember(byte[])command does a similar work but the returned element is not removed from the Set.Time complexity O(1)
- Specified by:
spopin interfaceSetBinaryCommands- Parameters:
key-- Returns:
- The removed member, or nil when key does not exist
-
spop
- Specified by:
spopin interfaceSetBinaryCommands
-
smove
public long smove(byte[] srckey, byte[] dstkey, byte[] member) Move the specified member from the set at srckey to the set at dstkey. This operation is atomic, in every given moment the element will appear to be in the source or destination set for accessing clients.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)
- Specified by:
smovein interfaceSetBinaryCommands- Parameters:
srckey-dstkey-member-- Returns:
- 1 if the element was moved, 0 if no operation was performed
-
scard
public long scard(byte[] key) Return the set cardinality (number of elements). If the key does not exist 0 is returned, like for empty sets.- Specified by:
scardin interfaceSetBinaryCommands- Parameters:
key-- Returns:
- The cardinality (number of elements) of the set
-
sismember
public boolean sismember(byte[] key, byte[] member) Return true if member is a member of the set stored at key, otherwise false is returned.Time complexity O(1)
- Specified by:
sismemberin interfaceSetBinaryCommands- Parameters:
key-member-- Returns:
trueif the element is a member of the set,falseotherwise
-
smismember
Returns whether each member is a member of the set stored at key.Time complexity O(N) where N is the number of elements being checked for membership
- Specified by:
smismemberin interfaceSetBinaryCommands- Parameters:
key-members-- Returns:
- List representing the membership of the given elements, in the same order as they are requested
-
sinter
Return the members of a set resulting from the intersection of all the sets hold at the specified keys. Like inlrange(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 asSMEMBERS. 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
- Specified by:
sinterin interfaceSetBinaryCommands- Parameters:
keys-- Returns:
- A set with members of the resulting set
-
sinterstore
public long sinterstore(byte[] dstkey, byte[]... keys) This command works exactly likeSINTERbut 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
- Specified by:
sinterstorein interfaceSetBinaryCommands- Parameters:
dstkey-keys-- Returns:
- The number of elements in the resulting set
-
sintercard
public long sintercard(byte[]... keys) This command works exactly likeSINTERbut instead of returning the result set, it returns just the cardinality of the result. LIMIT defaults to 0 and means unlimitedTime complexity O(N*M) worst case where N is the cardinality of the smallest
- Specified by:
sintercardin interfaceSetBinaryCommands- Parameters:
keys-- Returns:
- The cardinality of the set which would result from the intersection of all the given sets
-
sintercard
public long sintercard(int limit, byte[]... keys) This command works exactly likeSINTERbut instead of returning the result set, it returns just the cardinality of the result.Time complexity O(N*M) worst case where N is the cardinality of the smallest
- Specified by:
sintercardin interfaceSetBinaryCommands- Parameters:
limit- If the intersection cardinality reaches limit partway through the computation, the algorithm will exit and yield limit as the cardinality.keys-- Returns:
- The cardinality of the set which would result from the intersection of all the given sets
-
sunion
Return the members of a set resulting from the union of all the sets hold at the specified keys. Like inlrange(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 asSMEMBERS.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
- Specified by:
sunionin interfaceSetBinaryCommands- Parameters:
keys-- Returns:
- A set with members of the resulting set
-
sunionstore
public long sunionstore(byte[] dstkey, byte[]... keys) This command works exactly likeSUNIONbut 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
- Specified by:
sunionstorein interfaceSetBinaryCommands- Parameters:
dstkey-keys-- Returns:
- The number of elements in the resulting set
-
sdiff
Return the difference between the Set stored at key1 and all the Sets key2, ..., keyNExample:
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
- Specified by:
sdiffin interfaceSetBinaryCommands- Parameters:
keys-- Returns:
- A set with members of the resulting set
-
sdiffstore
public long sdiffstore(byte[] dstkey, byte[]... keys) This command works exactly likeSDIFFbut instead of being returned the resulting set is stored in dstkey.- Specified by:
sdiffstorein interfaceSetBinaryCommands- Parameters:
dstkey-keys-- Returns:
- The number of elements in the resulting set
-
srandmember
public byte[] srandmember(byte[] key) Return a random element from a Set, without removing the element. If the Set is empty or the key does not exist, a nil object is returned.The SPOP command does a similar work but the returned element is popped (removed) from the Set.
Time complexity O(1)
- Specified by:
srandmemberin interfaceSetBinaryCommands- Parameters:
key-- Returns:
- The randomly selected element
-
srandmember
- Specified by:
srandmemberin interfaceSetBinaryCommands
-
zadd
public long zadd(byte[] key, double score, byte[] member) Add the specified member having the specified score to the sorted set stored at key. If member is already a member of the sorted set the score is updated, and the element reinserted in the right position to ensure sorting. If key does not exist a new sorted set with the specified member as sole member is created. If the key exists but does not hold a sorted set value an error is returned.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
- Specified by:
zaddin interfaceSortedSetBinaryCommands- Parameters:
key-score-member-- Returns:
- 1 if the new element was added, 0 if the element was already a member of the sorted set and the score was updated
-
zadd
- Specified by:
zaddin interfaceSortedSetBinaryCommands
-
zadd
- Specified by:
zaddin interfaceSortedSetBinaryCommands
-
zadd
- Specified by:
zaddin interfaceSortedSetBinaryCommands
-
zaddIncr
- Specified by:
zaddIncrin interfaceSortedSetBinaryCommands
-
zrange
- Specified by:
zrangein interfaceSortedSetBinaryCommands
-
zrem
public long zrem(byte[] key, byte[]... members) Remove the specified member from the sorted set value stored at key. If member was not a member of the set no operation is performed. If key does not not hold a set value an error is returned.Time complexity O(log(N)) with N being the number of elements in the sorted set
- Specified by:
zremin interfaceSortedSetBinaryCommands- Parameters:
key-members-- Returns:
- 1 if the new element was removed, 0 if the new element was not a member of the set
-
zincrby
public 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. If member does not already exist in the sorted set it is added with increment as score (that is, like if the previous score was virtually zero). If key does not exist a new sorted set with the specified member as sole member is created. If the key exists but does not hold a sorted set value an error is returned.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
- Specified by:
zincrbyin interfaceSortedSetBinaryCommands- Parameters:
key-increment-member-- Returns:
- The new score
-
zincrby
- Specified by:
zincrbyin interfaceSortedSetBinaryCommands
-
zrank
Return the rank (or index) or member in the sorted set at key, with scores being ordered from low to high.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))
- Specified by:
zrankin interfaceSortedSetBinaryCommands- Parameters:
key-member-- Returns:
- The element as an integer if the element exists. A 'nil' bulk reply if there is no such element
- See Also:
-
zrevrank
Return the rank (or index) or member in the sorted set at key, with scores being ordered from high to low.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))
- Specified by:
zrevrankin interfaceSortedSetBinaryCommands- Parameters:
key-member-- Returns:
- The element as an integer if the element exists. A 'nil' bulk reply if there is no such element.
- See Also:
-
zrankWithScore
Returns the rank and the score of member in the sorted set stored at key, with the scores ordered from low to high.- Specified by:
zrankWithScorein interfaceSortedSetBinaryCommands- Parameters:
key- the keymember- the member- Returns:
- the KeyValue contains rank and score.
-
zrevrankWithScore
Returns the rank and the score of member in the sorted set stored at key, with the scores ordered from high to low.- Specified by:
zrevrankWithScorein interfaceSortedSetBinaryCommands- Parameters:
key- the keymember- the member- Returns:
- the KeyValue contains rank and score.
-
zrevrange
- Specified by:
zrevrangein interfaceSortedSetBinaryCommands
-
zrangeWithScores
- Specified by:
zrangeWithScoresin interfaceSortedSetBinaryCommands
-
zrevrangeWithScores
- Specified by:
zrevrangeWithScoresin interfaceSortedSetBinaryCommands
-
zrange
- Specified by:
zrangein interfaceSortedSetBinaryCommands
-
zrangeWithScores
- Specified by:
zrangeWithScoresin interfaceSortedSetBinaryCommands
-
zrangestore
- Specified by:
zrangestorein interfaceSortedSetBinaryCommands
-
zrandmember
public byte[] zrandmember(byte[] key) - Specified by:
zrandmemberin interfaceSortedSetBinaryCommands
-
zrandmember
- Specified by:
zrandmemberin interfaceSortedSetBinaryCommands
-
zrandmemberWithScores
- Specified by:
zrandmemberWithScoresin interfaceSortedSetBinaryCommands
-
zcard
public long zcard(byte[] key) Return the sorted set cardinality (number of elements). If the key does not exist 0 is returned, like for empty sorted sets.Time complexity O(1)
- Specified by:
zcardin interfaceSortedSetBinaryCommands- Parameters:
key-- Returns:
- The cardinality (number of elements) of the set as an integer.
-
zscore
Return the score of the specified element of the sorted set at key. If the specified element does not exist in the sorted set, or the key does not exist at all, a special 'nil' value is returned.Time complexity: O(1)
- Specified by:
zscorein interfaceSortedSetBinaryCommands- Parameters:
key-member-- Returns:
- The score
-
zmscore
Returns the scores associated with the specified members in the sorted set stored at key. For every member that does not exist in the sorted set, a nil value is returned.Time complexity: O(N) where N is the number of members being requested.
- Specified by:
zmscorein interfaceSortedSetBinaryCommands- Parameters:
key-members-- Returns:
- The scores
-
zpopmax
- Specified by:
zpopmaxin interfaceSortedSetBinaryCommands
-
zpopmax
- Specified by:
zpopmaxin interfaceSortedSetBinaryCommands
-
zpopmin
- Specified by:
zpopminin interfaceSortedSetBinaryCommands
-
zpopmin
- Specified by:
zpopminin interfaceSortedSetBinaryCommands
-
watch
-
unwatch
-
sort
Sort a Set or a List.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.
- Specified by:
sortin interfaceKeyBinaryCommands- Parameters:
key-- Returns:
- Assuming the Set/List at key contains a list of numbers, the return value will be the list of numbers ordered from the smallest to the biggest number.
- See Also:
-
sort
Sort a Set or a List accordingly to the specified parameters.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 = 7
Sort 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]
- Specified by:
sortin interfaceKeyBinaryCommands- Parameters:
key-sortingParams-- Returns:
- a list of sorted elements.
- See Also:
-
sort
Sort a Set or a List accordingly to the specified parameters and store the result at dstkey.- Specified by:
sortin interfaceKeyBinaryCommands- Parameters:
key-sortingParams-dstkey-- Returns:
- The number of elements of the list at dstkey.
- See Also:
-
sort
public long sort(byte[] key, byte[] dstkey) Sort a Set or a List and Store the Result at 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.
- Specified by:
sortin interfaceKeyBinaryCommands- Parameters:
key-dstkey-- Returns:
- The number of elements of the list at dstkey.
- See Also:
-
sortReadonly
- Specified by:
sortReadonlyin interfaceKeyBinaryCommands
-
lmove
Pop an element from a list, push it to another list and return it- Specified by:
lmovein interfaceListBinaryCommands- Parameters:
srcKey-dstKey-from-to-- Returns:
- The element being popped and pushed
-
blmove
public 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- Specified by:
blmovein interfaceListBinaryCommands- Parameters:
srcKey-dstKey-from-to-timeout-- Returns:
- The element being popped and pushed
-
blpop
BLPOP (and BRPOP) is a blocking list pop primitive. You can see this commands as blocking versions of LPOP and RPOP able to block if the specified keys don't exist or contain empty lists.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)
- Specified by:
blpopin interfaceListBinaryCommands- Parameters:
timeout-keys-- Returns:
- BLPOP returns a two-elements array via a multi bulk reply in order to return both the
unblocking key and the popped value.
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
- Specified by:
blpopin interfaceListBinaryCommands
-
brpop
BLPOP (and BRPOP) is a blocking list pop primitive. You can see this commands as blocking versions of LPOP and RPOP able to block if the specified keys don't exist or contain empty lists.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)
- Specified by:
brpopin interfaceListBinaryCommands- Parameters:
timeout-keys-- Returns:
- BLPOP returns a two-elements array via a multi bulk reply in order to return both the
unblocking key and the popped value.
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
- Specified by:
brpopin interfaceListBinaryCommands
-
lmpop
- Specified by:
lmpopin interfaceListBinaryCommands
-
lmpop
- Specified by:
lmpopin interfaceListBinaryCommands
-
blmpop
- Specified by:
blmpopin interfaceListBinaryCommands
-
blmpop
public KeyValue<byte[],List<byte[]>> blmpop(long timeout, ListDirection direction, int count, byte[]... keys) - Specified by:
blmpopin interfaceListBinaryCommands
-
bzpopmax
- Specified by:
bzpopmaxin interfaceSortedSetBinaryCommands
-
bzpopmin
- Specified by:
bzpopminin interfaceSortedSetBinaryCommands
-
auth
Request for authentication in a password protected Redis server. A Redis server can be instructed to require a password before to allow clients to issue commands. This is done using the requirepass directive in the Redis configuration file. If the password given by the connection is correct the server replies with an OK status code reply and starts accepting commands from the connection. Otherwise an error is returned and the clients needs to try a new password. Note that for the high performance nature of Redis it is possible to try a lot of passwords in parallel in very short time, so make sure to generate a strong and very long password so that this attack is infeasible.- Specified by:
authin interfaceServerCommands- Parameters:
password-- Returns:
- OK
-
auth
Request for authentication with a Redis Server that is using ACL where user are authenticated with username and password. See https://redis.io/topics/acl- Specified by:
authin interfaceServerCommands- Parameters:
user-password-- Returns:
- OK
-
zcount
public long zcount(byte[] key, double min, double max) - Specified by:
zcountin interfaceSortedSetBinaryCommands
-
zcount
public long zcount(byte[] key, byte[] min, byte[] max) - Specified by:
zcountin interfaceSortedSetBinaryCommands
-
zdiff
- Specified by:
zdiffin interfaceSortedSetBinaryCommands
-
zdiffWithScores
- Specified by:
zdiffWithScoresin interfaceSortedSetBinaryCommands
-
zdiffStore
public long zdiffStore(byte[] dstkey, byte[]... keys) - Specified by:
zdiffStorein interfaceSortedSetBinaryCommands
-
zrangeByScore
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).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
LIMITit is possible to get only a range of the matching elements in an SQL-alike way. Note that if the offset is large the commands needs to traverse the list for offset elements and this adds up to the O(M) figure.The
ZCOUNTcommand is similar toZRANGEBYSCOREbut 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 is possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10Will 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))
- Specified by:
zrangeByScorein interfaceSortedSetBinaryCommands- Parameters:
key-min-max-- Returns:
- A list of elements in the specified score range
- See Also:
-
zrangeByScore
- Specified by:
zrangeByScorein interfaceSortedSetBinaryCommands
-
zrangeByScore
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).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
LIMITit is 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
ZCOUNTcommand is similar toZRANGEBYSCOREbut 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 is possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10Will 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))
- Specified by:
zrangeByScorein interfaceSortedSetBinaryCommands- Parameters:
key-min-max-offset-count-- Returns:
- A list of elements in the specified score range
- See Also:
-
zrangeByScore
- Specified by:
zrangeByScorein interfaceSortedSetBinaryCommands
-
zrangeByScoreWithScores
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).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
LIMITit is 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
ZCOUNTcommand is similar toZRANGEBYSCOREbut 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 is possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10Will 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))
- Specified by:
zrangeByScoreWithScoresin interfaceSortedSetBinaryCommands- Parameters:
key-min-max-- Returns:
- A list of elements in the specified score range
- See Also:
-
zrangeByScoreWithScores
- Specified by:
zrangeByScoreWithScoresin interfaceSortedSetBinaryCommands
-
zrangeByScoreWithScores
public 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).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
LIMITit is 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
ZCOUNTcommand is similar toZRANGEBYSCOREbut 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 is possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10Will 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))
- Specified by:
zrangeByScoreWithScoresin interfaceSortedSetBinaryCommands- Parameters:
key-min-max-offset-count-- Returns:
- A list of elements in the specified score range
- See Also:
-
zrangeByScoreWithScores
public List<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max, int offset, int count) - Specified by:
zrangeByScoreWithScoresin interfaceSortedSetBinaryCommands
-
zrevrangeByScore
- Specified by:
zrevrangeByScorein interfaceSortedSetBinaryCommands
-
zrevrangeByScore
- Specified by:
zrevrangeByScorein interfaceSortedSetBinaryCommands
-
zrevrangeByScore
- Specified by:
zrevrangeByScorein interfaceSortedSetBinaryCommands
-
zrevrangeByScore
- Specified by:
zrevrangeByScorein interfaceSortedSetBinaryCommands
-
zrevrangeByScoreWithScores
- Specified by:
zrevrangeByScoreWithScoresin interfaceSortedSetBinaryCommands
-
zrevrangeByScoreWithScores
public List<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min, int offset, int count) - Specified by:
zrevrangeByScoreWithScoresin interfaceSortedSetBinaryCommands
-
zrevrangeByScoreWithScores
- Specified by:
zrevrangeByScoreWithScoresin interfaceSortedSetBinaryCommands
-
zrevrangeByScoreWithScores
public List<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min, int offset, int count) - Specified by:
zrevrangeByScoreWithScoresin interfaceSortedSetBinaryCommands
-
zremrangeByRank
public long zremrangeByRank(byte[] key, long start, long stop) Remove all elements in the sorted set at key with rank between start and end. Start and end are 0-based with rank 0 being the element with the lowest score. Both start and end can be negative numbers, where they indicate offsets starting at the element with the highest rank. For example: -1 is the element with the highest score, -2 the element with the second highest score and so forth.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
- Specified by:
zremrangeByRankin interfaceSortedSetBinaryCommands- Parameters:
key-start-stop-- Returns:
- The number of elements removed
-
zremrangeByScore
public 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).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
- Specified by:
zremrangeByScorein interfaceSortedSetBinaryCommands- Parameters:
key-min-max-- Returns:
- The number of elements removed
-
zremrangeByScore
public long zremrangeByScore(byte[] key, byte[] min, byte[] max) - Specified by:
zremrangeByScorein interfaceSortedSetBinaryCommands
-
zunion
Add multiple sorted sets, This command is similar to ZUNIONSTORE, but instead of storing the resulting sorted set, it is returned to the connection.- Specified by:
zunionin interfaceSortedSetBinaryCommands- Parameters:
params-keys-- Returns:
- The result of the union
-
zunionWithScores
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.- Specified by:
zunionWithScoresin interfaceSortedSetBinaryCommands- Parameters:
params-keys-- Returns:
- The result of the union with their scores
-
zunionstore
public 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. It is mandatory to provide the number of input keys N, before passing the input keys and the other (optional) arguments.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. Thezunionstore(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 is 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
- Specified by:
zunionstorein interfaceSortedSetBinaryCommands- Parameters:
dstkey-sets-- Returns:
- The number of elements in the sorted set at dstkey
-
zunionstore
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. It is mandatory to provide the number of input keys N, before passing the input keys and the other (optional) arguments.As the terms imply, the
ZINTERSTOREcommand requires an element to be present in each of the given inputs to be inserted in the result. TheZUNIONSTOREcommand 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 is 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
- Specified by:
zunionstorein interfaceSortedSetBinaryCommands- Parameters:
dstkey-params-sets-- Returns:
- The number of elements in the sorted set at dstkey
-
zinter
Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the connection.- Specified by:
zinterin interfaceSortedSetBinaryCommands- Parameters:
params-keys-- Returns:
- The result of the intersection
-
zinterWithScores
Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the connection.- Specified by:
zinterWithScoresin interfaceSortedSetBinaryCommands- Parameters:
params-keys-- Returns:
- The result of the intersection with scores
-
zinterstore
public 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. It is mandatory to provide the number of input keys N, before passing the input keys and the other (optional) arguments.As the terms imply, the
ZINTERSTOREcommand requires an element to be present in each of the given inputs to be inserted in the result. TheZUNIONSTOREcommand 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 is 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
- Specified by:
zinterstorein interfaceSortedSetBinaryCommands- Parameters:
dstkey-sets-- Returns:
- The number of elements in the sorted set at dstkey
-
zinterstore
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. It is mandatory to provide the number of input keys N, before passing the input keys and the other (optional) arguments.As the terms imply, the
ZINTERSTOREcommand requires an element to be present in each of the given inputs to be inserted in the result. TheZUNIONSTOREcommand 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 is 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
- Specified by:
zinterstorein interfaceSortedSetBinaryCommands- Parameters:
dstkey-params-sets-- Returns:
- The number of elements in the sorted set at dstkey
-
zintercard
public long zintercard(byte[]... keys) Description copied from interface:SortedSetBinaryCommandsSimilar toZINTER, but instead of returning the result set, it returns just the cardinality of the result.Time complexity O(N*K) worst case with N being the smallest input sorted set, K being the number of input sorted sets
- Specified by:
zintercardin interfaceSortedSetBinaryCommands- Parameters:
keys- group of sets- Returns:
- The number of elements in the resulting intersection
- See Also:
-
zintercard
public long zintercard(long limit, byte[]... keys) Description copied from interface:SortedSetBinaryCommandsSimilar toZINTER, but instead of returning the result set, it returns just the cardinality of the result.Time complexity O(N*K) worst case with N being the smallest input sorted set, K being the number of input sorted sets
- Specified by:
zintercardin interfaceSortedSetBinaryCommands- Parameters:
limit- If the intersection cardinality reaches limit partway through the computation, the algorithm will exit and yield limit as the cardinalitykeys- group of sets- Returns:
- The number of elements in the resulting intersection
- See Also:
-
zlexcount
public long zlexcount(byte[] key, byte[] min, byte[] max) - Specified by:
zlexcountin interfaceSortedSetBinaryCommands
-
zrangeByLex
- Specified by:
zrangeByLexin interfaceSortedSetBinaryCommands
-
zrangeByLex
- Specified by:
zrangeByLexin interfaceSortedSetBinaryCommands
-
zrevrangeByLex
- Specified by:
zrevrangeByLexin interfaceSortedSetBinaryCommands
-
zrevrangeByLex
- Specified by:
zrevrangeByLexin interfaceSortedSetBinaryCommands
-
zremrangeByLex
public long zremrangeByLex(byte[] key, byte[] min, byte[] max) - Specified by:
zremrangeByLexin interfaceSortedSetBinaryCommands
-
zmpop
- Specified by:
zmpopin interfaceSortedSetBinaryCommands
-
zmpop
- Specified by:
zmpopin interfaceSortedSetBinaryCommands
-
bzmpop
- Specified by:
bzmpopin interfaceSortedSetBinaryCommands
-
bzmpop
public KeyValue<byte[],List<Tuple>> bzmpop(long timeout, SortedSetOption option, int count, byte[]... keys) - Specified by:
bzmpopin interfaceSortedSetBinaryCommands
-
save
Synchronously save the DB on disk.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
BGSAVEthat is able to perform the saving in the background while the server continues serving other clients.- Specified by:
savein interfaceServerCommands- Returns:
- OK
-
bgsave
Asynchronously save the DB on disk.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.
- Specified by:
bgsavein interfaceServerCommands- Returns:
- OK
-
bgsaveSchedule
- Specified by:
bgsaveSchedulein interfaceServerCommands
-
bgrewriteaof
Rewrite the append only file in background when it gets too big. Please for detailed information about the Redis Append Only File check the Append Only File Howto.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.
- Specified by:
bgrewriteaofin interfaceServerCommands- Returns:
- OK
-
lastsave
public long lastsave()Return the UNIX time stamp of the last successfully saving of the dataset on disk.Return the UNIX TIME of the last DB save executed with success. A connection may check if a
BGSAVEcommand succeeded reading the LASTSAVE value, then issuing a BGSAVE command and checking at regular intervals every N seconds if LASTSAVE changed.- Specified by:
lastsavein interfaceServerCommands- Returns:
- An UNIX time stamp
-
shutdown
Synchronously save the DB on disk, then shutdown the server.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
SAVEand thenQUITbecause other clients may alter the DB data between the two commands.- Specified by:
shutdownin interfaceServerCommands- Throws:
JedisException- with the status code reply on error. On success nothing is thrown since the server quits and the connection is closed.
-
shutdown
Deprecated.- Specified by:
shutdownin interfaceServerCommands- Parameters:
saveMode- modifier to alter the data save behavior of SHUTDOWN.nullwould trigger the default behavior.- Throws:
JedisException- See Also:
-
shutdown
- Specified by:
shutdownin interfaceServerCommands- Parameters:
shutdownParams- set commands parameters- Throws:
JedisException- See Also:
-
shutdownAbort
- Specified by:
shutdownAbortin interfaceServerCommands
-
info
Provide information and statistics about the server.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:0
Notesused_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.
- Specified by:
infoin interfaceServerCommands- Returns:
- Bulk reply
-
info
Description copied from interface:ServerCommandsThe 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.- Specified by:
infoin interfaceServerCommands- Parameters:
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)- Returns:
- info
-
monitor
Dump all the received requests in real time.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.
- Parameters:
jedisMonitor-
-
slaveof
Deprecated.Change the replication settings.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.
- Specified by:
slaveofin interfaceServerCommands- Parameters:
host-port-- Returns:
- OK
-
slaveofNoOne
Deprecated.UsereplicaofNoOne().Description copied from interface:ServerCommandsSLAVEOF NO ONE will stop replication, turning the server into a MASTER, but will not discard the replication. So, if the old master stops working, it is possible to turn the slave into a master and set the application to use this new master in read/write. Later when the other Redis server is fixed, it can be reconfigured to work as a slave.- Specified by:
slaveofNoOnein interfaceServerCommands- Returns:
- result of the command
-
replicaof
Description copied from interface:ServerCommandsThe REPLICAOF command can change the replication settings of a replica on the fly. In the proper form REPLICAOF hostname port will make the server a replica of another server listening at the specified hostname and port. If a server is already a replica of some master, REPLICAOF hostname port will stop the replication against the old server and start the synchronization against the new one, discarding the old dataset.- Specified by:
replicaofin interfaceServerCommands- Parameters:
host- listening at the specified hostnameport- server listening at the specified port- Returns:
- result of the command.
-
replicaofNoOne
Description copied from interface:ServerCommandsREPLICAOF NO ONE will stop replication, turning the server into a MASTER, but will not discard the replication. So, if the old master stops working, it is possible to turn the replica into a master and set the application to use this new master in read/write. Later when the other Redis server is fixed, it can be reconfigured to work as a replica.- Specified by:
replicaofNoOnein interfaceServerCommands- Returns:
- result of the command
-
roleBinary
Description copied from interface:ControlBinaryCommandsProvide information on the role of a Redis instance in the context of replication, by returning if the instance is currently a master, slave, or sentinel. The command also returns additional information about the state of the replication (if the role is master or slave) or the list of monitored master names (if the role is sentinel).- Specified by:
roleBinaryin interfaceControlBinaryCommands- Returns:
- The information on the role of a Redis instance
-
configGet
Retrieve the configuration of a running Redis server. Not all the configuration parameters are supported.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"
- Specified by:
configGetin interfaceConfigCommands- Parameters:
pattern-- Returns:
- Bulk reply.
-
configGet
Description copied from interface:ConfigCommandsUsed to read the configuration parameters of Redis server.- Specified by:
configGetin interfaceConfigCommands- Parameters:
patterns- names of Redis server's configuration- Returns:
- values of Redis server's configuration
-
configResetStat
Reset the stats returned by INFO- Specified by:
configResetStatin interfaceConfigCommands- Returns:
- always OK.
-
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.The rewrite is performed in a very conservative way:
- Comments and the overall structure of the original redis.conf are preserved as much as possible.
- If an option already exists in the old redis.conf file, it will be rewritten at the same position (line number).
- If an option was not already present, but it is set to its default value, it is not added by the rewrite process.
- If an option was not already present, but it is set to a non-default value, it is appended at the end of the file.
- Non used lines are blanked. For instance if you used to have multiple save directives, but the current configuration has fewer or none as you disabled RDB persistence, all the lines will be blanked.
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.
- Specified by:
configRewritein interfaceConfigCommands- Returns:
- OK when the configuration was rewritten properly. Otherwise an error is returned.
-
configSet
Alter the configuration of a running Redis server. Not all the configuration parameters are supported.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:
- The save parameter is a list of space-separated integers. Every pair of integers specify the time and number of changes limit to trigger a save. For instance the command CONFIG SET save "3600 10 60 10000" will configure the server to issue a background saving of the RDB file every 3600 seconds if there are at least 10 changes in the dataset, and every 60 seconds if there are at least 10000 changes. To completely disable automatic snapshots just set the parameter as an empty string.
- All the integer parameters representing memory are returned and accepted only using bytes as unit.
- Specified by:
configSetin interfaceConfigCommands- Parameters:
parameter-value-- Returns:
- OK
-
configSet
- Specified by:
configSetin interfaceConfigCommands
-
strlen
public long strlen(byte[] key) - Specified by:
strlenin interfaceStringBinaryCommands
-
strAlgoLCSKeys
Deprecated.STRALGO LCS command will be removed from Redis 7.LCScan be used instead of this method.- Specified by:
strAlgoLCSKeysin interfaceStringBinaryCommands
-
strAlgoLCSStrings
@Deprecated public LCSMatchResult strAlgoLCSStrings(byte[] strA, byte[] strB, StrAlgoLCSParams params) Deprecated.STRALGO LCS command will be removed from Redis 7. -
lcs
Description copied from interface:StringBinaryCommandsCalculate the longest common subsequence of keyA and keyB.- Specified by:
lcsin interfaceStringBinaryCommands- Parameters:
keyA-keyB-params-- Returns:
- According to LCSParams to decide to return content to fill LCSMatchResult.
-
lpushx
public long lpushx(byte[] key, byte[]... strings) - Specified by:
lpushxin interfaceListBinaryCommands
-
persist
public long persist(byte[] key) Undo aexpireat turning the expire key into a normal key.Time complexity: O(1)
- Specified by:
persistin interfaceKeyBinaryCommands- Parameters:
key-- Returns:
- 1 if the key is now persist, 0 if the key is not persist (only happens when key not set)
-
rpushx
public long rpushx(byte[] key, byte[]... strings) - Specified by:
rpushxin interfaceListBinaryCommands
-
echo
public byte[] echo(byte[] string) - Specified by:
echoin interfaceServerCommands
-
linsert
- Specified by:
linsertin interfaceListBinaryCommands
-
brpoplpush
public 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- Specified by:
brpoplpushin interfaceListBinaryCommands
-
setbit
public boolean setbit(byte[] key, long offset, boolean value) Sets or clears the bit at offset in the string value stored at key- Specified by:
setbitin interfaceBitBinaryCommands
-
getbit
public boolean getbit(byte[] key, long offset) Returns the bit value at offset in the string value stored at key- Specified by:
getbitin interfaceBitBinaryCommands
-
bitpos
public long bitpos(byte[] key, boolean value) - Specified by:
bitposin interfaceBitBinaryCommands
-
bitpos
- Specified by:
bitposin interfaceBitBinaryCommands
-
setrange
public long setrange(byte[] key, long offset, byte[] value) - Specified by:
setrangein interfaceStringBinaryCommands
-
getrange
public byte[] getrange(byte[] key, long startOffset, long endOffset) - Specified by:
getrangein interfaceStringBinaryCommands
-
publish
public long publish(byte[] channel, byte[] message) -
subscribe
-
psubscribe
-
eval
Evaluates scripts using the Lua interpreter built into Redis starting from version 2.6.0.- Specified by:
evalin interfaceScriptingKeyBinaryCommands- Parameters:
script-keys-args-- Returns:
- Script result
-
evalReadonly
- Specified by:
evalReadonlyin interfaceScriptingKeyBinaryCommands
-
getParamsWithBinary
-
eval
- Specified by:
evalin interfaceScriptingKeyBinaryCommands
-
eval
- Specified by:
evalin interfaceScriptingKeyBinaryCommands
-
evalsha
- Specified by:
evalshain interfaceScriptingKeyBinaryCommands
-
evalsha
- Specified by:
evalshain interfaceScriptingKeyBinaryCommands
-
evalshaReadonly
- Specified by:
evalshaReadonlyin interfaceScriptingKeyBinaryCommands
-
evalsha
- Specified by:
evalshain interfaceScriptingKeyBinaryCommands
-
scriptFlush
- Specified by:
scriptFlushin interfaceScriptingControlCommands
-
scriptFlush
- Specified by:
scriptFlushin interfaceScriptingControlCommands
-
scriptExists
- Specified by:
scriptExistsin interfaceScriptingControlCommands
-
scriptExists
- Specified by:
scriptExistsin interfaceScriptingControlCommands
-
scriptLoad
public byte[] scriptLoad(byte[] script) - Specified by:
scriptLoadin interfaceScriptingControlCommands
-
scriptKill
- Specified by:
scriptKillin interfaceScriptingControlCommands
-
slowlogReset
- Specified by:
slowlogResetin interfaceSlowlogCommands
-
slowlogLen
public long slowlogLen()- Specified by:
slowlogLenin interfaceSlowlogCommands
-
slowlogGetBinary
- Specified by:
slowlogGetBinaryin interfaceSlowlogCommands
-
slowlogGetBinary
- Specified by:
slowlogGetBinaryin interfaceSlowlogCommands
-
objectRefcount
Description copied from interface:ControlBinaryCommandsReturns the reference count of the stored atkey.- Specified by:
objectRefcountin interfaceControlBinaryCommands- Specified by:
objectRefcountin interfaceKeyBinaryCommands- Parameters:
key- The key in Redis server- Returns:
- The reference count of the stored at
key
-
objectEncoding
public byte[] objectEncoding(byte[] key) Description copied from interface:ControlBinaryCommandsReturns the internal encoding for the Redis object stored atkey.See for details: OBJECT ENCODING key
- Specified by:
objectEncodingin interfaceControlBinaryCommands- Specified by:
objectEncodingin interfaceKeyBinaryCommands- Parameters:
key- The key in Redis server- Returns:
- The number of references
-
objectIdletime
Description copied from interface:ControlBinaryCommandsReturns the time in seconds since the last access to the value stored atkey. The command is only available when the maxmemory-policy configuration directive is not set to one of the LFU policies.- Specified by:
objectIdletimein interfaceControlBinaryCommands- Specified by:
objectIdletimein interfaceKeyBinaryCommands- Parameters:
key- The key in Redis server- Returns:
- The idle time in seconds
-
objectHelpBinary
Description copied from interface:ControlBinaryCommandsReturns the object subcommands and usages.- Specified by:
objectHelpBinaryin interfaceControlBinaryCommands- Returns:
- object subcommands and usages
-
objectFreq
Description copied from interface:ControlBinaryCommandsReturns the logarithmic access frequency counter of a Redis object stored atkey.The command is only available when the maxmemory-policy configuration directive is set to one of the LFU policies.
- Specified by:
objectFreqin interfaceControlBinaryCommands- Specified by:
objectFreqin interfaceKeyBinaryCommands- Parameters:
key- The key in Redis server- Returns:
- The counter's value
-
bitcount
public long bitcount(byte[] key) - Specified by:
bitcountin interfaceBitBinaryCommands
-
bitcount
public long bitcount(byte[] key, long start, long end) - Specified by:
bitcountin interfaceBitBinaryCommands
-
bitcount
- Specified by:
bitcountin interfaceBitBinaryCommands
-
bitop
- Specified by:
bitopin interfaceBitBinaryCommands
-
dump
public byte[] dump(byte[] key) - Specified by:
dumpin interfaceKeyBinaryCommands
-
restore
- Specified by:
restorein interfaceKeyBinaryCommands
-
restore
- Specified by:
restorein interfaceKeyBinaryCommands
-
pttl
public long pttl(byte[] key) - Specified by:
pttlin interfaceKeyBinaryCommands
-
psetex
PSETEX works exactly likesetex(byte[], long, byte[])with the sole difference that the expire time is specified in milliseconds instead of seconds. Time complexity: O(1)- Specified by:
psetexin interfaceStringBinaryCommands- Parameters:
key-milliseconds-value-- Returns:
- OK
-
memoryDoctorBinary
public byte[] memoryDoctorBinary()Description copied from interface:ControlBinaryCommandsReports about different memory-related issues that the Redis server experiences, and advises about possible remedies.- Specified by:
memoryDoctorBinaryin interfaceControlBinaryCommands
-
memoryUsage
Description copied from interface:ControlBinaryCommandsReports the number of bytes that a key and its value require to be stored in RAM. The reported usage is the total of memory allocations for data and administrative overheads that a key its value require.See for details: MEMORY USAGE key
- Specified by:
memoryUsagein interfaceControlBinaryCommands- Specified by:
memoryUsagein interfaceKeyBinaryCommands- Parameters:
key- The key in Redis server- Returns:
- The memory usage in bytes, or nil when the key does not exist
-
memoryUsage
Description copied from interface:ControlBinaryCommandsReports the number of bytes that a key and its value require to be stored in RAM. The reported usage is the total of memory allocations for data and administrative overheads that a key its value require.See for details: MEMORY USAGE key SAMPLES count
- Specified by:
memoryUsagein interfaceControlBinaryCommands- Specified by:
memoryUsagein interfaceKeyBinaryCommands- Parameters:
key- The key in Redis server- Returns:
- The memory usage in bytes, or nil when the key does not exist
-
failover
- Specified by:
failoverin interfaceGenericControlCommands
-
failover
- Specified by:
failoverin interfaceGenericControlCommands
-
failoverAbort
- Specified by:
failoverAbortin interfaceGenericControlCommands
-
aclWhoAmIBinary
public byte[] aclWhoAmIBinary()Description copied from interface:AccessControlLogBinaryCommandsReturns the username used to authenticate the current connection.- Specified by:
aclWhoAmIBinaryin interfaceAccessControlLogBinaryCommands- Returns:
- The username used for the current connection
- See Also:
-
aclGenPassBinary
public byte[] aclGenPassBinary()Description copied from interface:AccessControlLogBinaryCommandsGenerate a random password- Specified by:
aclGenPassBinaryin interfaceAccessControlLogBinaryCommands- Returns:
- A random password
- See Also:
-
aclGenPassBinary
public byte[] aclGenPassBinary(int bits) Description copied from interface:AccessControlLogBinaryCommandsGenerate a random password- Specified by:
aclGenPassBinaryin interfaceAccessControlLogBinaryCommands- Parameters:
bits- the number of output bits- Returns:
- A random password
-
aclListBinary
Description copied from interface:AccessControlLogBinaryCommandsReturns the currently active ACL rules on the Redis Server- Specified by:
aclListBinaryin interfaceAccessControlLogBinaryCommands- Returns:
- An array of ACL rules
- See Also:
-
aclUsersBinary
Description copied from interface:AccessControlLogBinaryCommandsShows a list of all usernames currently configured with access control lists (ACL).- Specified by:
aclUsersBinaryin interfaceAccessControlLogBinaryCommands- Returns:
- list of users
- See Also:
-
aclGetUser
Description copied from interface:AccessControlLogBinaryCommandsThe command returns all the rules defined for an existing ACL user.- Specified by:
aclGetUserin interfaceAccessControlLogBinaryCommands- Parameters:
name- username- Returns:
- a list of ACL rule definitions for the user.
-
aclSetUser
Description copied from interface:AccessControlLogBinaryCommandsCreate an ACL for the specified user with the default rules.- Specified by:
aclSetUserin interfaceAccessControlLogBinaryCommands- Parameters:
name- user who receives an acl- Returns:
- A string containing OK on success
- See Also:
-
aclSetUser
Description copied from interface:AccessControlLogBinaryCommandsCreate an ACL for the specified user, while specifying the rules.- Specified by:
aclSetUserin interfaceAccessControlLogBinaryCommands- Parameters:
name- user who receives an aclkeys- the acl rules for the specified user- Returns:
- A string containing OK on success
- See Also:
-
aclDelUser
public long aclDelUser(byte[] name) Description copied from interface:AccessControlLogBinaryCommandsDelete the specified user, from the ACL.- Specified by:
aclDelUserin interfaceAccessControlLogBinaryCommands- Parameters:
name- The username to delete- Returns:
- The number of users delete
- See Also:
-
aclDelUser
public long aclDelUser(byte[] name, byte[]... names) Description copied from interface:AccessControlLogBinaryCommandsDelete the specified users, from the ACL.- Specified by:
aclDelUserin interfaceAccessControlLogBinaryCommands- Parameters:
name- The username to deletenames- Other usernames to delete- Returns:
- The number of users delete
- See Also:
-
aclCatBinary
Description copied from interface:AccessControlLogBinaryCommandsShow the available ACL categories.- Specified by:
aclCatBinaryin interfaceAccessControlLogBinaryCommands- Returns:
- the available ACL categories
- See Also:
-
aclCat
Description copied from interface:AccessControlLogBinaryCommandsShow the available ACLs for a given category.- Specified by:
aclCatin interfaceAccessControlLogBinaryCommands- Parameters:
category- The category for which to list available ACLs- Returns:
- the available ACL categories
- See Also:
-
aclLogBinary
Description copied from interface:AccessControlLogBinaryCommandsShows the recent ACL security events.- Specified by:
aclLogBinaryin interfaceAccessControlLogBinaryCommands- Returns:
- The list of recent security events
- See Also:
-
aclLogBinary
Description copied from interface:AccessControlLogBinaryCommandsShows the recent limit ACL security events.- Specified by:
aclLogBinaryin interfaceAccessControlLogBinaryCommands- Parameters:
limit- The number of results to return- Returns:
- The list of recent security events
- See Also:
-
aclLogReset
Description copied from interface:AccessControlLogCommandsReset the script event log- Specified by:
aclLogResetin interfaceAccessControlLogBinaryCommands- Specified by:
aclLogResetin interfaceAccessControlLogCommands- Returns:
- The OK string
- See Also:
-
clientKill
Description copied from interface:ClientBinaryCommandsClose a given client connection.- Specified by:
clientKillin interfaceClientBinaryCommands- Parameters:
ipPort- The ip:port should match a line returned by the CLIENT LIST command (addr field).- Returns:
- close success return OK
-
clientKill
Description copied from interface:ClientCommandsClose a given client connection.- Specified by:
clientKillin interfaceClientBinaryCommands- Specified by:
clientKillin interfaceClientCommands- Parameters:
ip- The ip should match a line returned by the CLIENT LIST command (addr field).port- The port should match a line returned by the CLIENT LIST command (addr field).- Returns:
- Close success return OK
-
clientKill
Description copied from interface:ClientCommandsClose a given client connection.- Specified by:
clientKillin interfaceClientBinaryCommands- Specified by:
clientKillin interfaceClientCommands- Parameters:
params- Connection info will be closed- Returns:
- Close success return OK
-
clientGetnameBinary
public byte[] clientGetnameBinary()Description copied from interface:ClientBinaryCommandsReturns the name of the current connection as set by CLIENT SETNAME- Specified by:
clientGetnameBinaryin interfaceClientBinaryCommands- Returns:
- Current connect name
-
clientListBinary
public byte[] clientListBinary()Description copied from interface:ClientBinaryCommandsReturns information and statistics about the client connections server in a mostly human readable format.- Specified by:
clientListBinaryin interfaceClientBinaryCommands- Returns:
- All clients info connected to redis-server
-
clientListBinary
Description copied from interface:ClientBinaryCommandsReturns information and statistics about the client connections server in a mostly human readable format filter by client type.- Specified by:
clientListBinaryin interfaceClientBinaryCommands- Returns:
- all clients info connected to redis-server
-
clientListBinary
public byte[] clientListBinary(long... clientIds) Description copied from interface:ClientBinaryCommandsReturns information and statistics about the client connections server in a mostly human readable format filter by client ids.- Specified by:
clientListBinaryin interfaceClientBinaryCommands- Parameters:
clientIds- Unique 64-bit client IDs- Returns:
- All clients info connected to redis-server
-
clientListParams
private byte[][] clientListParams(long... clientIds) -
clientInfoBinary
public byte[] clientInfoBinary()Description copied from interface:ClientBinaryCommandsReturns information and statistics about the current client connection in a mostly human readable format.- Specified by:
clientInfoBinaryin interfaceClientBinaryCommands- Returns:
- Information and statistics about the current client connection
-
clientSetInfo
Description copied from interface:ClientBinaryCommandsclient set info command Since redis 7.2- Specified by:
clientSetInfoin interfaceClientBinaryCommands- Parameters:
attr- the attr optionvalue- the value- Returns:
- OK or error
-
clientSetname
Description copied from interface:ClientBinaryCommandsAssigns a name to the current connection.- Specified by:
clientSetnamein interfaceClientBinaryCommands- Parameters:
name- Current connection name- Returns:
- OK if the connection name was successfully set.
-
clientId
public long clientId()Description copied from interface:ClientCommandsReturns the ID of the current connection.- Specified by:
clientIdin interfaceClientBinaryCommands- Specified by:
clientIdin interfaceClientCommands- Returns:
- The id of the client.
-
clientUnblock
public long clientUnblock(long clientId) Unblock a connection blocked in a blocking command from a different connection.- Specified by:
clientUnblockin interfaceClientBinaryCommands- Specified by:
clientUnblockin interfaceClientCommands- Parameters:
clientId-- Returns:
- 1 if the client was unblocked successfully, 0 if the client wasn't unblocked.
-
clientUnblock
Unblock a connection blocked in a blocking command from a different connection.- Specified by:
clientUnblockin interfaceClientBinaryCommands- Specified by:
clientUnblockin interfaceClientCommands- Parameters:
clientId-unblockType-- Returns:
- 1 if the client was unblocked successfully, 0 if the client wasn't unblocked.
-
clientPause
Description copied from interface:ClientCommandsA connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds)- Specified by:
clientPausein interfaceClientBinaryCommands- Specified by:
clientPausein interfaceClientCommands- Parameters:
timeout- WRITE|ALL- Returns:
- The command returns OK or an error if the timeout is invalid.
-
clientPause
Description copied from interface:ClientCommandsA connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds)- Specified by:
clientPausein interfaceClientBinaryCommands- Specified by:
clientPausein interfaceClientCommands- Parameters:
timeout- Command timeoutmode- WRITE|ALL- Returns:
- The command returns OK or an error if the timeout is invalid.
-
clientUnpause
Description copied from interface:ClientCommandsCLIENT UNPAUSE is used to resume command processing for all clients that were paused by CLIENT PAUSE.- Specified by:
clientUnpausein interfaceClientBinaryCommands- Specified by:
clientUnpausein interfaceClientCommands- Returns:
- OK
-
clientNoEvictOn
Description copied from interface:ClientCommandsTurn on the client eviction mode for the current connection.- Specified by:
clientNoEvictOnin interfaceClientBinaryCommands- Specified by:
clientNoEvictOnin interfaceClientCommands- Returns:
- OK
-
clientNoEvictOff
Description copied from interface:ClientCommandsTurn off the client eviction mode for the current connection.- Specified by:
clientNoEvictOffin interfaceClientBinaryCommands- Specified by:
clientNoEvictOffin interfaceClientCommands- Returns:
- OK
-
clientNoTouchOn
Description copied from interface:ClientCommandsTurn on CLIENT NO-TOUCH- Specified by:
clientNoTouchOnin interfaceClientCommands- Returns:
- OK
-
clientNoTouchOff
Description copied from interface:ClientCommandsTurn off CLIENT NO-TOUCH- Specified by:
clientNoTouchOffin interfaceClientCommands- Returns:
- OK
-
time
-
migrate
Description copied from interface:DatabaseCommandsBinary version ofMIGRATE.- Specified by:
migratein interfaceDatabaseCommands- See Also:
-
migrate
public String migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, byte[]... keys) Description copied from interface:DatabaseCommandsBinary version ofMIGRATE.- Specified by:
migratein interfaceDatabaseCommands- See Also:
-
migrate
- Specified by:
migratein interfaceKeyBinaryCommands
-
migrate
- Specified by:
migratein interfaceKeyBinaryCommands
-
waitReplicas
public long waitReplicas(int replicas, long timeout) Description copied from interface:ServerCommandsSynchronous replication of Redis as described here: http://antirez.com/news/66.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
waitmethod, we cannot use it.- Specified by:
waitReplicasin interfaceServerCommands- Parameters:
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 forever- Returns:
- the number of replicas reached by all the writes performed in the context of the current connection
-
waitAOF
Description copied from interface:ServerCommandsBlocks the current client until all the previous write commands are acknowledged as having been fsynced to the AOF of the local Redis and/or at least the specified number of replicas. Redis Documentation- Specified by:
waitAOFin interfaceServerCommands- Parameters:
numLocal- Number of local instances that are required to acknowledge the sync (0 or 1), cannot be non-zero if the local Redis does not have AOF enablednumReplicas- Number of replicas that are required to acknowledge the synctimeout- Timeout in millis of the operation - if 0 timeout is unlimited. If the timeout is reached, the command returns even if the specified number of acknowledgments has not been met.- Returns:
- KeyValue where Key is number of local Redises (0 or 1) that have fsynced to AOF all writes performed in the context of the current connection, and the value is the number of replicas that have acknowledged doing the same.
-
pfadd
public long pfadd(byte[] key, byte[]... elements) - Specified by:
pfaddin interfaceHyperLogLogBinaryCommands
-
pfcount
public long pfcount(byte[] key) - Specified by:
pfcountin interfaceHyperLogLogBinaryCommands
-
pfmerge
- Specified by:
pfmergein interfaceHyperLogLogBinaryCommands
-
pfcount
public long pfcount(byte[]... keys) - Specified by:
pfcountin interfaceHyperLogLogBinaryCommands
-
scan
- Specified by:
scanin interfaceKeyBinaryCommands
-
scan
- Specified by:
scanin interfaceKeyBinaryCommands
-
scan
- Specified by:
scanin interfaceKeyBinaryCommands
-
hscan
- Specified by:
hscanin interfaceHashBinaryCommands
-
hscan
- Specified by:
hscanin interfaceHashBinaryCommands
-
sscan
- Specified by:
sscanin interfaceSetBinaryCommands
-
sscan
- Specified by:
sscanin interfaceSetBinaryCommands
-
zscan
- Specified by:
zscanin interfaceSortedSetBinaryCommands
-
zscan
- Specified by:
zscanin interfaceSortedSetBinaryCommands
-
geoadd
public long geoadd(byte[] key, double longitude, double latitude, byte[] member) - Specified by:
geoaddin interfaceGeoBinaryCommands
-
geoadd
- Specified by:
geoaddin interfaceGeoBinaryCommands
-
geoadd
- Specified by:
geoaddin interfaceGeoBinaryCommands
-
geodist
- Specified by:
geodistin interfaceGeoBinaryCommands
-
geodist
- Specified by:
geodistin interfaceGeoBinaryCommands
-
geohash
- Specified by:
geohashin interfaceGeoBinaryCommands
-
geopos
- Specified by:
geoposin interfaceGeoBinaryCommands
-
georadius
public List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude, double radius, GeoUnit unit) - Specified by:
georadiusin interfaceGeoBinaryCommands
-
georadiusReadonly
public List<GeoRadiusResponse> georadiusReadonly(byte[] key, double longitude, double latitude, double radius, GeoUnit unit) - Specified by:
georadiusReadonlyin interfaceGeoBinaryCommands
-
georadius
public List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param) - Specified by:
georadiusin interfaceGeoBinaryCommands
-
georadiusStore
public long georadiusStore(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam) - Specified by:
georadiusStorein interfaceGeoBinaryCommands
-
georadiusReadonly
public List<GeoRadiusResponse> georadiusReadonly(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param) - Specified by:
georadiusReadonlyin interfaceGeoBinaryCommands
-
georadiusByMember
public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit) - Specified by:
georadiusByMemberin interfaceGeoBinaryCommands
-
georadiusByMemberReadonly
public List<GeoRadiusResponse> georadiusByMemberReadonly(byte[] key, byte[] member, double radius, GeoUnit unit) - Specified by:
georadiusByMemberReadonlyin interfaceGeoBinaryCommands
-
georadiusByMember
public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param) - Specified by:
georadiusByMemberin interfaceGeoBinaryCommands
-
georadiusByMemberStore
public long georadiusByMemberStore(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam) - Specified by:
georadiusByMemberStorein interfaceGeoBinaryCommands
-
geosearch
- Specified by:
geosearchin interfaceGeoBinaryCommands
-
geosearch
public List<GeoRadiusResponse> geosearch(byte[] key, GeoCoordinate coord, double radius, GeoUnit unit) - Specified by:
geosearchin interfaceGeoBinaryCommands
-
geosearch
public List<GeoRadiusResponse> geosearch(byte[] key, byte[] member, double width, double height, GeoUnit unit) - Specified by:
geosearchin interfaceGeoBinaryCommands
-
geosearch
public List<GeoRadiusResponse> geosearch(byte[] key, GeoCoordinate coord, double width, double height, GeoUnit unit) - Specified by:
geosearchin interfaceGeoBinaryCommands
-
geosearch
- Specified by:
geosearchin interfaceGeoBinaryCommands
-
geosearchStore
- Specified by:
geosearchStorein interfaceGeoBinaryCommands
-
geosearchStore
public long geosearchStore(byte[] dest, byte[] src, GeoCoordinate coord, double radius, GeoUnit unit) - Specified by:
geosearchStorein interfaceGeoBinaryCommands
-
geosearchStore
public long geosearchStore(byte[] dest, byte[] src, byte[] member, double width, double height, GeoUnit unit) - Specified by:
geosearchStorein interfaceGeoBinaryCommands
-
geosearchStore
public long geosearchStore(byte[] dest, byte[] src, GeoCoordinate coord, double width, double height, GeoUnit unit) - Specified by:
geosearchStorein interfaceGeoBinaryCommands
-
geosearchStore
- Specified by:
geosearchStorein interfaceGeoBinaryCommands
-
geosearchStoreStoreDist
- Specified by:
geosearchStoreStoreDistin interfaceGeoBinaryCommands
-
georadiusByMemberReadonly
public List<GeoRadiusResponse> georadiusByMemberReadonly(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param) - Specified by:
georadiusByMemberReadonlyin interfaceGeoBinaryCommands
-
bitfield
- Specified by:
bitfieldin interfaceBitBinaryCommands
-
bitfieldReadonly
- Specified by:
bitfieldReadonlyin interfaceBitBinaryCommands
-
hstrlen
public long hstrlen(byte[] key, byte[] field) - Specified by:
hstrlenin interfaceHashBinaryCommands
-
xread
- Specified by:
xreadin interfaceStreamBinaryCommands
-
xreadGroup
public List<Object> xreadGroup(byte[] groupName, byte[] consumer, XReadGroupParams xReadGroupParams, Map.Entry<byte[], byte[]>... streams) - Specified by:
xreadGroupin interfaceStreamBinaryCommands
-
xadd
- Specified by:
xaddin interfaceStreamBinaryCommands
-
xlen
public long xlen(byte[] key) - Specified by:
xlenin interfaceStreamBinaryCommands
-
xrange
- Specified by:
xrangein interfaceStreamBinaryCommands
-
xrange
- Specified by:
xrangein interfaceStreamBinaryCommands
-
xrevrange
- Specified by:
xrevrangein interfaceStreamBinaryCommands
-
xrevrange
- Specified by:
xrevrangein interfaceStreamBinaryCommands
-
xack
public long xack(byte[] key, byte[] group, byte[]... ids) - Specified by:
xackin interfaceStreamBinaryCommands
-
xgroupCreate
- Specified by:
xgroupCreatein interfaceStreamBinaryCommands
-
xgroupSetID
- Specified by:
xgroupSetIDin interfaceStreamBinaryCommands
-
xgroupDestroy
public long xgroupDestroy(byte[] key, byte[] consumer) - Specified by:
xgroupDestroyin interfaceStreamBinaryCommands
-
xgroupCreateConsumer
public boolean xgroupCreateConsumer(byte[] key, byte[] groupName, byte[] consumerName) - Specified by:
xgroupCreateConsumerin interfaceStreamBinaryCommands
-
xgroupDelConsumer
public long xgroupDelConsumer(byte[] key, byte[] groupName, byte[] consumerName) - Specified by:
xgroupDelConsumerin interfaceStreamBinaryCommands
-
xdel
public long xdel(byte[] key, byte[]... ids) - Specified by:
xdelin interfaceStreamBinaryCommands
-
xtrim
public long xtrim(byte[] key, long maxLen, boolean approximateLength) - Specified by:
xtrimin interfaceStreamBinaryCommands
-
xtrim
- Specified by:
xtrimin interfaceStreamBinaryCommands
-
xpending
@Deprecated public List<Object> xpending(byte[] key, byte[] groupName, byte[] start, byte[] end, int count, byte[] consumerName) Deprecated.- Specified by:
xpendingin interfaceStreamBinaryCommands
-
xpending
- Specified by:
xpendingin interfaceStreamBinaryCommands
-
xpending
- Specified by:
xpendingin interfaceStreamBinaryCommands
-
xclaim
public List<byte[]> xclaim(byte[] key, byte[] group, byte[] consumerName, long minIdleTime, XClaimParams params, byte[]... ids) - Specified by:
xclaimin interfaceStreamBinaryCommands
-
xclaimJustId
public List<byte[]> xclaimJustId(byte[] key, byte[] group, byte[] consumerName, long minIdleTime, XClaimParams params, byte[]... ids) - Specified by:
xclaimJustIdin interfaceStreamBinaryCommands
-
xautoclaim
public List<Object> xautoclaim(byte[] key, byte[] groupName, byte[] consumerName, long minIdleTime, byte[] start, XAutoClaimParams params) - Specified by:
xautoclaimin interfaceStreamBinaryCommands
-
xautoclaimJustId
public List<Object> xautoclaimJustId(byte[] key, byte[] groupName, byte[] consumerName, long minIdleTime, byte[] start, XAutoClaimParams params) - Specified by:
xautoclaimJustIdin interfaceStreamBinaryCommands
-
xinfoStream
- Specified by:
xinfoStreamin interfaceStreamBinaryCommands
-
xinfoStreamFull
Description copied from interface:StreamBinaryCommandsIntrospection command used in order to retrieve all information about the stream- Specified by:
xinfoStreamFullin interfaceStreamBinaryCommands- Parameters:
key- Stream name
-
xinfoStreamFull
Description copied from interface:StreamBinaryCommandsIntrospection command used in order to retrieve all information about the stream- Specified by:
xinfoStreamFullin interfaceStreamBinaryCommands- Parameters:
key- Stream namecount- stream info count
-
xinfoGroup
Deprecated.- Specified by:
xinfoGroupin interfaceStreamBinaryCommands
-
xinfoGroups
- Specified by:
xinfoGroupsin interfaceStreamBinaryCommands
-
xinfoConsumers
- Specified by:
xinfoConsumersin interfaceStreamBinaryCommands
-
sendCommand
-
sendBlockingCommand
-
sendCommand
-
copy
COPY source destination [DB destination-db] [REPLACE]- Specified by:
copyin interfaceDatabaseCommands- Parameters:
srcKey- the source key.dstKey- the destination key.db-replace-
-
copy
COPY source destination [REPLACE]- Specified by:
copyin interfaceKeyCommands- Parameters:
srcKey- the source key.dstKey- the destination key.replace-- Returns:
trueif source was copied,falseotherwise
-
ping
Works same asping()but returns argument message instead of PONG.- Specified by:
pingin interfaceServerCommands- Parameters:
message-- Returns:
- message
-
set
Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1 GB).Time complexity: O(1)
- Specified by:
setin interfaceStringCommands- Parameters:
key-value-- Returns:
- OK
-
set
Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1 GB).- Specified by:
setin interfaceStringCommands- Parameters:
key-value-params- NX|XX, NX -- Only set the key if it does not already exist. XX -- Only set the key if it already exists. EX|PX, expire time units: EX = seconds; PX = milliseconds- Returns:
- simple-string-reply
OKifSETwas executed correctly, ornullif theSEToperation was not performed because the user specified the NX or XX option but the condition was not met.
-
get
Get the value of the specified key. If the key does not exist the special value 'nil' is returned. If the value stored at key is not a string an error is returned because GET can only handle string values.Time complexity: O(1)
- Specified by:
getin interfaceStringCommands- Parameters:
key-- Returns:
- Bulk reply
-
setGet
Description copied from interface:StringCommandsWARNING:SetParams.get()MUST NOT be used with this method.- Specified by:
setGetin interfaceStringCommands
-
getDel
Get the value of key and delete the key. This command is similar to GET, except for the fact that it also deletes the key on success (if and only if the key's value type is a string).Time complexity: O(1)
- Specified by:
getDelin interfaceStringCommands- Parameters:
key-- Returns:
- The value of key
-
getEx
Description copied from interface:StringCommandsGetEx Command Get the value of key and optionally set its expiration. GETEX is similar toGET, but is a write command with additional options: EX seconds -- Set the specified expire time, in seconds. PX milliseconds -- Set the specified expire time, in milliseconds. EXAT timestamp-seconds -- Set the specified Unix time at which the key will expire, in seconds. PXAT timestamp-milliseconds -- Set the specified Unix time at which the key will expire, in milliseconds. PERSIST -- Remove the time to live associated with the key.Time complexity: O(1)
- Specified by:
getExin interfaceStringCommands- Parameters:
key-params-GetExParams- Returns:
- The value stored in key
-
exists
Test if the specified keys exist. The command returns the number of keys exist. Time complexity: O(N)- Specified by:
existsin interfaceKeyCommands- Parameters:
keys-- Returns:
- The number of keys that exist from those specified as
keys
-
exists
Test if the specified key exists. The command returns true if the key exists, otherwise false is returned. Note that even keys set with an empty string as value will return true. Time complexity: O(1)- Specified by:
existsin interfaceKeyCommands- Parameters:
key-- Returns:
trueif the key exists, otherwisefalse
-
del
Remove the specified keys. If a given key does not exist no operation is performed for this key. The command returns the number of keys removed. Time complexity: O(1)- Specified by:
delin interfaceKeyCommands- Parameters:
keys-- Returns:
- An integer greater than 0 if one or more keys were removed, 0 if none of the specified keys existed
-
del
Description copied from interface:KeyCommandsDel Command Remove the specified key. If a given key does not exist, no operation is performed.Time complexity: O(1)
- Specified by:
delin interfaceKeyCommands- Parameters:
key-- Returns:
- 1 if the key was removed, 0 if the key does not exist
-
unlink
This command is very similar to DEL: it removes the specified keys. Just like DEL a key is ignored if it does not exist. However the command performs the actual memory reclaiming in a different thread, so it is not blocking, while DEL is. This is where the command name comes from: the command just unlinks the keys from the keyspace. The actual removal will happen later asynchronously.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.
- Specified by:
unlinkin interfaceKeyCommands- Parameters:
keys-- Returns:
- The number of keys that were unlinked
- See Also:
-
unlink
Description copied from interface:KeyCommandsUnlink Command This command is very similar toDEL: it removes the specified key. Just like DEL a key is ignored if it does not exist. However, the command performs the actual memory reclaiming in a different thread, so it is not blocking, while DEL is. This is where the command name comes from: the command just unlinks the keys from the keyspace. The actual removal will happen later asynchronously.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.
- Specified by:
unlinkin interfaceKeyCommands- Parameters:
key-- Returns:
- The number of keys that were unlinked
-
type
Return the type of the value stored at key in form of a string. The type can be one of "none", "string", "list", "set". "none" is returned if the key does not exist. Time complexity: O(1)- Specified by:
typein interfaceKeyCommands- Parameters:
key-- Returns:
- "none" if the key does not exist, "string" if the key contains a String value, "list" if the key contains a List value, "set" if the key contains a Set value, "zset" if the key contains a Sorted Set value, "hash" if the key contains a Hash value
-
keys
Description copied from interface:KeyCommandsKeys Command Returns all the keys matching the glob-style pattern as space separated strings. For example if you have in the database the keys "foo" and "foobar" the command "KEYS foo*" will return "foo foobar".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:
- h?llo will match hello hallo hhllo
- h*llo will match hllo heeeello
- h[ae]llo will match hello and hallo, but not hillo
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)
- Specified by:
keysin interfaceKeyCommands- Parameters:
pattern-- Returns:
- List of keys matching the pattern.
-
randomKey
Return a randomly selected key from the currently selected DB.Time complexity: O(1)
- Specified by:
randomKeyin interfaceKeyCommands- Returns:
- Randomly selected key or an empty string if the database is empty
-
rename
Atomically renames the key oldkey to newkey. If the source and destination name are the same an error is returned. If newkey already exists it is overwritten.Time complexity: O(1)
- Specified by:
renamein interfaceKeyCommands- Parameters:
oldkey-newkey-- Returns:
- OK
-
renamenx
Rename oldkey into newkey but fails if the destination key newkey already exists.Time complexity: O(1)
- Specified by:
renamenxin interfaceKeyCommands- Parameters:
oldkey-newkey-- Returns:
- 1 if the key was renamed, 0 if the target key already exist
-
expire
Set a timeout on the specified key. After the timeout the key will be automatically deleted by the server. A key with an associated timeout is said to be volatile in Redis terminology.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
PERSISTcommand.Time complexity: O(1)
- Specified by:
expirein interfaceKeyCommands- Parameters:
key-seconds-- Returns:
- 1: the timeout was set. 0: the timeout was not set since the key already has an associated timeout (this may happen only in Redis versions < 2.1.3, Redis >= 2.1.3 will happily update the timeout), or the key does not exist.
- See Also:
-
expire
Similar toEXPIREbut with optional expiry setting.- Specified by:
expirein interfaceKeyCommands- Parameters:
key-seconds- time to expireexpiryOption- can be NX, XX, GT or LT- Returns:
- 1 if the timeout was set, 0 otherwise. Since the key already has an associated timeout (this may happen only in Redis versions < 2.1.3, Redis >= 2.1.3 will happily update the timeout), or the key does not exist.
- See Also:
-
pexpire
Description copied from interface:KeyCommandsPExpire Command This command works exactly likeEXPIREbut the time to live of the key is specified in milliseconds instead of seconds.Time complexity: O(1)
- Specified by:
pexpirein interfaceKeyCommands- Parameters:
key-milliseconds- time to expire- Returns:
- 1 if the timeout was set, 0 otherwise. e.g. key doesn't exist, or operation skipped due to the provided arguments.
-
pexpire
Description copied from interface:KeyCommandsSimilar toEXPIREbut with optional expiry setting.- Specified by:
pexpirein interfaceKeyCommands- Parameters:
key-milliseconds- time to expireexpiryOption- can be NX, XX, GT or LT- Returns:
- 1 if the timeout was set, 0 otherwise. e.g. key doesn't exist, or operation skipped due to the provided arguments.
- See Also:
-
expireTime
Returns the absolute Unix timestamp (since January 1, 1970) in seconds at which the given key will expire.The command returns -1 if the key exists but has no associated expiration time, and -2 if the key does not exist.
Time complexity: O(1)
- Specified by:
expireTimein interfaceKeyCommands- Parameters:
key-- Returns:
- Expiration Unix timestamp in seconds, or a negative value in order to signal an error: -1 if the key exists but has no associated expiration time, and -2 if the key does not exist.
-
pexpireTime
Similar toEXPIRETIMEbut returns the absolute Unix expiration timestamp in milliseconds instead of seconds.Time complexity: O(1)
- Specified by:
pexpireTimein interfaceKeyCommands- Parameters:
key-- Returns:
- Expiration Unix timestamp in milliseconds, or a negative value in order to signal an error: -1 if the key exists but has no associated expiration time, and -2 if the key does not exist.
- See Also:
-
expireAt
EXPIREAT works exactly likeEXPIREbut 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
PERSISTcommand.Time complexity: O(1)
- Specified by:
expireAtin interfaceKeyCommands- Parameters:
key-unixTime-- Returns:
- 1: the timeout was set. 0: the timeout was not set since the key already has an associated timeout (this may happen only in Redis versions < 2.1.3, Redis >= 2.1.3 will happily update the timeout), or the key does not exist.
- See Also:
-
expireAt
Similar toEXPIREATbut withExpiryOption.- Specified by:
expireAtin interfaceKeyCommands- Parameters:
key-unixTime- time to expireexpiryOption- can be NX, XX, GT or LT- Returns:
- 1 if the timeout was set, 0 otherwise. e.g. key doesn't exist, or operation skipped due to the provided arguments.
- See Also:
-
pexpireAt
This command works exactly likeEXPIREATbut Unix time at which the key will expire is specified in milliseconds instead of seconds.Time complexity: O(1)
- Specified by:
pexpireAtin interfaceKeyCommands- Parameters:
key-millisecondsTimestamp- time to expire- Returns:
- 1 if the timeout was set, 0 otherwise. e.g. key doesn't exist, or operation skipped due to the provided arguments.
-
pexpireAt
- Specified by:
pexpireAtin interfaceKeyCommands- Parameters:
key-millisecondsTimestamp- time to expireexpiryOption- can be NX, XX, GT or LT- Returns:
- 1 if the timeout was set, 0 otherwise. e.g. key doesn't exist, or operation skipped due to the provided arguments.
- See Also:
-
ttl
The TTL command returns the remaining time to live in seconds of a key that has anEXPIREset. This introspection capability allows a Redis connection to check how many seconds a given key will continue to be part of the dataset.- Specified by:
ttlin interfaceKeyCommands- Parameters:
key-- Returns:
- TTL in seconds, or a negative value in order to signal an error
-
touch
Alters the last access time of a key(s). A key is ignored if it does not exist. Time complexity: O(N) where N is the number of keys that will be touched.- Specified by:
touchin interfaceKeyCommands- Parameters:
keys-- Returns:
- The number of keys that were touched.
-
touch
Description copied from interface:KeyCommandsTouch Command Alters the last access time of a key. A key is ignored if it does not exist.Time complexity: O(N) where N is the number of keys that will be touched.
- Specified by:
touchin interfaceKeyCommands- Parameters:
key-- Returns:
- The number of keys that were touched
-
move
Move the specified key from the currently selected DB to the specified destination DB. Note that this command returns 1 only if the key was successfully moved, and 0 if the target key was already there or if the source key was not found at all, so it is possible to use MOVE as a locking primitive.- Specified by:
movein interfaceDatabaseCommands- Parameters:
key-dbIndex-- Returns:
- 1 if the key was moved, 0 if the key was not moved because already present on the target DB or was not found in the current DB
-
getSet
GETSET is an atomic set this value and return the old value command. Set key to the string value and return the old value stored at key. The string can't be longer than 1073741824 bytes (1 GB).Time complexity: O(1)
- Specified by:
getSetin interfaceStringCommands- Parameters:
key-value-- Returns:
- Bulk reply
-
mget
Get the values of all the specified keys. If one or more keys don't exist or is not of type String, a 'nil' value is returned instead of the value of the specified key, but the operation never fails.Time complexity: O(1) for every key
- Specified by:
mgetin interfaceStringCommands- Parameters:
keys-- Returns:
- Multi bulk reply
-
setnx
SETNX works exactly likeSETwith the only difference that if the key already exists no operation is performed. SETNX actually means "SET if Not eXists".Time complexity: O(1)
- Specified by:
setnxin interfaceStringCommands- Parameters:
key-value-- Returns:
- 1 if the key was set, 0 if the key was not set
-
setex
The command is exactly equivalent to the following group of commands:SET+EXPIRE. The operation is atomic.Time complexity: O(1)
- Specified by:
setexin interfaceStringCommands- Parameters:
key-seconds-value-- Returns:
- OK
-
mset
Set the the respective keys to the respective values. MSET will replace old values with new values, whileMSETNXwill 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.
- Specified by:
msetin interfaceStringCommands- Parameters:
keysvalues-- Returns:
- OK
- See Also:
-
msetnx
Set the the respective keys to the respective values.MSETwill 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.
- Specified by:
msetnxin interfaceStringCommands- Parameters:
keysvalues-- Returns:
- 1 if the all the keys were set, 0 if no key was set (at least one key already existed)
- See Also:
-
decrBy
IDECRBY work just likeINCRbut 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)
- Specified by:
decrByin interfaceStringCommands- Parameters:
key-decrement-- Returns:
- The value of key after the decrement
- See Also:
-
decr
Decrement the number stored at key by one. If the key does not exist or contains a value of a wrong type, set the key to the value of "0" before to perform the decrement operation.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)
- Specified by:
decrin interfaceStringCommands- Parameters:
key-- Returns:
- The value of key after the decrement
- See Also:
-
incrBy
INCRBY work just likeINCRbut 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)
- Specified by:
incrByin interfaceStringCommands- Parameters:
key-increment-- Returns:
- The value of key after the increment
- See Also:
-
incrByFloat
INCRBYFLOATINCRBYFLOAT 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)
- Specified by:
incrByFloatin interfaceStringCommands- Parameters:
key-increment-- Returns:
- The value of key after the increment
-
incr
Increment the number stored at key by one. If the key does not exist or contains a value of a wrong type, set the key to the value of "0" before to perform the increment operation.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)
- Specified by:
incrin interfaceStringCommands- Parameters:
key-- Returns:
- The value of key after the increment
- See Also:
-
append
If the key already exists and is a string, this command appends the provided value at the end of the string. If the key does not exist it is created and set as an empty string, so APPEND will be very similar to SET in this special case.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.
- Specified by:
appendin interfaceStringCommands- Parameters:
key-value-- Returns:
- The total length of the string after the append operation.
-
substr
Return a subset of the string from offset start to offset end (both offsets are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the string. So -1 means the last char, -2 the penultimate and so forth.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.
- Specified by:
substrin interfaceStringCommands- Parameters:
key-start-end-- Returns:
- The substring
-
hset
Set the specified hash field to the specified value.If key does not exist, a new key holding a hash is created.
Time complexity: O(1)
- Specified by:
hsetin interfaceHashCommands- Parameters:
key-field-value-- Returns:
- If the field already exists, and the HSET just produced an update of the value, 0 is returned, otherwise if a new field is created 1 is returned.
-
hset
- Specified by:
hsetin interfaceHashCommands
-
hget
If key holds a hash, retrieve the value associated to the specified field.If the field is not found or the key does not exist, a special 'nil' value is returned.
Time complexity: O(1)
- Specified by:
hgetin interfaceHashCommands- Parameters:
key-field-- Returns:
- Bulk reply
-
hsetnx
Set the specified hash field to the specified value if the field not exists. Time complexity: O(1)- Specified by:
hsetnxin interfaceHashCommands- Parameters:
key-field-value-- Returns:
- If the field already exists, 0 is returned, otherwise if a new field is created 1 is returned.
-
hmset
Set the respective fields to the respective values. HMSET replaces old values with new values.If key does not exist, a new key holding a hash is created.
Time complexity: O(N) (with N being the number of fields)
- Specified by:
hmsetin interfaceHashCommands- Parameters:
key-hash-- Returns:
- Return OK or Exception if hash is empty
-
hmget
Retrieve the values associated to the specified 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)
- Specified by:
hmgetin interfaceHashCommands- Parameters:
key-fields-- Returns:
- A list of all the values associated with the specified fields, in the same order of the request.
-
hincrBy
Increment the number stored at field in the hash at key by value. If key does not exist, a new key holding a hash is created. If field does not exist or holds a string, the value is set to 0 before applying the operation. Since the value argument is signed you can use this command to perform both increments and decrements.The range of values supported by HINCRBY is limited to 64 bit signed integers.
Time complexity: O(1)
- Specified by:
hincrByin interfaceHashCommands- Parameters:
key-field-value-- Returns:
- The value of key after the increment
-
hincrByFloat
Increment the number stored at field in the hash at key by a double precision floating point value. If key does not exist, a new key holding a hash is created. If field does not exist or holds a string, the value is set to 0 before applying the operation. Since the value argument is signed you can use this command to perform both increments and decrements.The range of values supported by HINCRBYFLOAT is limited to double precision floating point values.
Time complexity: O(1)
- Specified by:
hincrByFloatin interfaceHashCommands- Parameters:
key-field-value-- Returns:
- The new value at field after the increment operation
-
hexists
Test for existence of a specified field in a hash. Time complexity: O(1)- Specified by:
hexistsin interfaceHashCommands- Parameters:
key-field-- Returns:
trueif the hash stored at key contains the specified field,falseif the key is not found or the field is not present.
-
hdel
Remove the specified field(s) from a hash stored at key. Specified fields that do not exist within this hash are ignored.Time complexity: O(1)
- Specified by:
hdelin interfaceHashCommands- Parameters:
key-fields-- Returns:
- The number of fields that were removed from the hash, not including specified but non-existing fields. If key does not exist, it is treated as an empty hash and this command returns 0.
-
hlen
Return the number of items in a hash.Time complexity: O(1)
- Specified by:
hlenin interfaceHashCommands- Parameters:
key-- Returns:
- The number of entries (fields) contained in the hash stored at key. If the specified key does not exist, 0 is returned assuming an empty hash.
-
hkeys
Return all the fields in a hash.Time complexity: O(N), where N is the total number of entries
- Specified by:
hkeysin interfaceHashCommands- Parameters:
key-- Returns:
- All the fields names contained into a hash.
-
hvals
Return all the values in a hash.Time complexity: O(N), where N is the total number of entries
- Specified by:
hvalsin interfaceHashCommands- Parameters:
key-- Returns:
- All the fields values contained into a hash.
-
hgetAll
Return all the fields and associated values in a hash.Time complexity: O(N), where N is the total number of entries
- Specified by:
hgetAllin interfaceHashCommands- Parameters:
key-- Returns:
- All the fields and values contained into a hash.
-
hrandfield
Get one random field from a hash.Time complexity: O(N), where N is the number of fields returned
- Specified by:
hrandfieldin interfaceHashCommands- Parameters:
key-- Returns:
- one random field from a hash.
-
hrandfield
Get multiple random fields from a hash.Time complexity: O(N), where N is the number of fields returned
- Specified by:
hrandfieldin interfaceHashCommands- Parameters:
key-count-- Returns:
- multiple random fields from a hash.
-
hrandfieldWithValues
Get one or multiple random fields with values from a hash.Time complexity: O(N), where N is the number of fields returned
- Specified by:
hrandfieldWithValuesin interfaceHashCommands- Parameters:
key-count-- Returns:
- one or multiple random fields with values from a hash.
-
rpush
Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key. If the key does not exist an empty list is created just before the append operation. If the key exists but is not a List an error is returned.Time complexity: O(1)
- Specified by:
rpushin interfaceListCommands- Parameters:
key-strings-- Returns:
- The number of elements inside the list after the push operation
-
lpush
Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key. If the key does not exist an empty list is created just before the append operation. If the key exists but is not a List an error is returned.Time complexity: O(1)
- Specified by:
lpushin interfaceListCommands- Parameters:
key-strings-- Returns:
- The number of elements inside the list after the push operation
-
llen
Return the length of the list stored at the specified key. If the key does not exist zero is returned (the same behaviour as for empty lists). If the value stored at key is not a list an error is returned.Time complexity: O(1)
- Specified by:
llenin interfaceListCommands- Parameters:
key-- Returns:
- The length of the list
-
lrange
Return the specified elements of the list stored at the specified key. Start and end are zero-based indexes. 0 is the first element of the list (the list head), 1 the next element and so on.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)
- Specified by:
lrangein interfaceListCommands- Parameters:
key-start-stop-- Returns:
- A list of elements in the specified range
-
ltrim
Trim an existing list so that it will contain only the specified range of elements specified. Start and end are zero-based indexes. 0 is the first element of the list (the list head), 1 the next element and so on.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)
- Specified by:
ltrimin interfaceListCommands- Parameters:
key-start-stop-- Returns:
- OK
-
lindex
Return the specified element of the list stored at the specified key. 0 is the first element, 1 the second and so on. Negative indexes are supported, for example -1 is the last element, -2 the penultimate and so on.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)
- Specified by:
lindexin interfaceListCommands- Parameters:
key-index-- Returns:
- The requested element
-
lset
Set a new value as the element at index position of the List at key.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).
- Specified by:
lsetin interfaceListCommands- Parameters:
key-index-value-- Returns:
- OK
- See Also:
-
lrem
Remove the first count occurrences of the value element from the list. If count is zero all the elements are removed. If count is negative elements are removed from tail to head, instead to go from head to tail that is the normal behaviour. So for example LREM with count -2 and hello as value to remove against the list (a,b,c,hello,x,hello,hello) will leave the list (a,b,c,hello,x). The number of removed elements is returned as an integer, see below for more information about the returned value. Note that non existing keys are considered like empty lists by LREM, so LREM against non existing keys will always return 0.Time complexity: O(N) (with N being the length of the list)
- Specified by:
lremin interfaceListCommands- Parameters:
key-count-value-- Returns:
- The number of removed elements if the operation succeeded
-
lpop
Atomically return and remove the first (LPOP) or last (RPOP) element of the list. For example if the list contains the elements "a","b","c" LPOP will return "a" and the list will become "b","c".If the key does not exist or the list is already empty the special value 'nil' is returned.
- Specified by:
lpopin interfaceListCommands- Parameters:
key-- Returns:
- Bulk reply
- See Also:
-
lpop
Description copied from interface:ListCommandsAtomically return and remove the first (LPOP) or last (RPOP) element of the list. For example if the list contains the elements "a","b","c" LPOP will return "a" and the list will become "b","c".- Specified by:
lpopin interfaceListCommands- Parameters:
key-count-- Returns:
- A list of popped elements, or 'nil' when key does not exist
-
lpos
Description copied from interface:ListCommandsReturns the index of the first matching element inside a redis list. If the element is found, its index (the zero-based position in the list) is returned. Otherwise, if no match is found, 'nil' is returned.Time complexity: O(N) where N is the number of elements in the list
- Specified by:
lposin interfaceListCommands- Parameters:
key-element-- Returns:
- The index of first matching element in the list. Value will be 'nil' when the element is not present in the list
-
lpos
Description copied from interface:ListCommandsIn case there are multiple matches Rank option specifies the "rank" of the element to return. A rank of 1 returns the first match, 2 to return the second match, and so forth. If list `foo` has elements ("a","b","c","1","2","3","c","c"), The function call to get the index of second occurrence of "c" will be as follows lpos("foo","c", LPosParams.lPosParams().rank(2)).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)).
- Specified by:
lposin interfaceListCommands- Parameters:
key-element-params-LPosParams- Returns:
- The integer representing the matching element, or 'nil' if there is no match
-
lpos
Description copied from interface:ListCommandsReturns the index of matching elements inside a Redis list. If the element is found, its index (the zero-based position in the list) is returned. Otherwise, if no match is found, nil is returned.Time complexity: O(N) where N is the number of elements in the list
- Specified by:
lposin interfaceListCommands- Parameters:
key-element-params-LPosParamscount-- Returns:
- A list containing position of the matching elements inside the list
-
rpop
Atomically return and remove the first (LPOP) or last (RPOP) element of the list. For example if the list contains the elements "a","b","c" RPOP will return "c" and the list will become "a","b".If the key does not exist or the list is already empty the special value 'nil' is returned.
- Specified by:
rpopin interfaceListCommands- Parameters:
key-- Returns:
- Bulk reply
- See Also:
-
rpop
Description copied from interface:ListCommandsAtomically return and remove the first (LPOP) or last (RPOP) element of the list. For example if the list contains the elements "a","b","c" LPOP will return "a" and the list will become "b","c".- Specified by:
rpopin interfaceListCommands- Parameters:
key-count- return up to count elements- Returns:
- A list of count popped elements, or 'nil' when key does not exist.
-
rpoplpush
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. For example if the source list contains the elements "a","b","c" and the destination list contains the elements "foo","bar" after an RPOPLPUSH command the content of the two lists will be "a","b" and "c","foo","bar".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)
- Specified by:
rpoplpushin interfaceListCommands- Parameters:
srckey-dstkey-- Returns:
- Bulk reply
-
sadd
Add the specified member to the set value stored at key. If member is already a member of the set no operation is performed. If key does not exist a new set with the specified member as sole member is created. If the key exists but does not hold a set value an error is returned.Time complexity O(1)
- Specified by:
saddin interfaceSetCommands- Parameters:
key-members-- Returns:
- 1 if the new element was added, 0 if the element was already a member of the set
-
smembers
Return all the members (elements) of the set value stored at key. This is just syntax glue forSINTER.Time complexity O(N)
- Specified by:
smembersin interfaceSetCommands- Parameters:
key-- Returns:
- Multi bulk reply
-
srem
Remove the specified member from the set value stored at key. If member was not a member of the set no operation is performed. If key does not hold a set value an error is returned.Time complexity O(1)
- Specified by:
sremin interfaceSetCommands- Parameters:
key-members-- Returns:
- 1 if the new element was removed, 0 if the new element was not a member of the set
-
spop
Remove a random element from a Set returning it as return value. If the Set is empty or the key does not exist, a nil object is returned.The
srandmember(String)command does a similar work but the returned element is not removed from the Set.Time complexity O(1)
- Specified by:
spopin interfaceSetCommands- Parameters:
key-- Returns:
- Bulk reply
-
spop
Description copied from interface:SetCommandsBy default, the commandSetCommands.spop(String)pops a single member from the set. In this command, the reply will consist of up to count members, depending on the set's cardinality.The
SetCommands.srandmember(String)command does a similar work but the returned element is not removed from the Set.Time complexity O(N), where N is the value of the passed count
- Specified by:
spopin interfaceSetCommands- Parameters:
key-count-- Returns:
- The removed members
-
smove
Move the specified member from the set at srckey to the set at dstkey. This operation is atomic, in every given moment the element will appear to be in the source or destination set for accessing clients.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)
- Specified by:
smovein interfaceSetCommands- Parameters:
srckey-dstkey-member-- Returns:
- 1 if the element was moved, 0 if the element was not found on the first set and no operation was performed
-
scard
Return the set cardinality (number of elements). If the key does not exist 0 is returned, like for empty sets.- Specified by:
scardin interfaceSetCommands- Parameters:
key-- Returns:
- The cardinality (number of elements) of the set as an integer
-
sismember
Return true if member is a member of the set stored at key, otherwise false is returned.Time complexity O(1)
- Specified by:
sismemberin interfaceSetCommands- Parameters:
key-member-- Returns:
trueif the element is a member of the set,falseotherwise
-
smismember
Returns whether each member is a member of the set stored at key.Time complexity O(N) where N is the number of elements being checked for membership
- Specified by:
smismemberin interfaceSetCommands- Parameters:
key-members-- Returns:
- List representing the membership of the given elements, in the same order as they are requested
-
sinter
Return the members of a set resulting from the intersection of all the sets hold at the specified keys. Like inLRANGEthe 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 asSMEMBERS. 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
- Specified by:
sinterin interfaceSetCommands- Parameters:
keys-- Returns:
- A set with members of the resulting set
-
sinterstore
This command works exactly likeSINTERbut 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
- Specified by:
sinterstorein interfaceSetCommands- Parameters:
dstkey-keys-- Returns:
- The number of elements in the resulting set
-
sintercard
This command works exactly likeSINTERbut instead of returning the result set, it returns just the cardinality of the result.Time complexity O(N*M) worst case where N is the cardinality of the smallest
- Specified by:
sintercardin interfaceSetCommands- Parameters:
keys-- Returns:
- The cardinality of the set which would result from the intersection of all the given sets
-
sintercard
This command works exactly likeSINTERbut instead of returning the result set, it returns just the cardinality of the result.Time complexity O(N*M) worst case where N is the cardinality of the smallest
- Specified by:
sintercardin interfaceSetCommands- Parameters:
limit- If the intersection cardinality reaches limit partway through the computation, the algorithm will exit and yield limit as the cardinality.keys-- Returns:
- The cardinality of the set which would result from the intersection of all the given sets
-
sunion
Return the members of a set resulting from the union of all the sets hold at the specified keys. Like inLRANGEthe 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 asSMEMBERS.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
- Specified by:
sunionin interfaceSetCommands- Parameters:
keys-- Returns:
- A set with members of the resulting set
-
sunionstore
This command works exactly likeSUNIONbut 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
- Specified by:
sunionstorein interfaceSetCommands- Parameters:
dstkey-keys-- Returns:
- The number of elements in the resulting set
-
sdiff
Return the difference between the Set stored at key1 and all the Sets key2, ..., keyNExample:
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
- Specified by:
sdiffin interfaceSetCommands- Parameters:
keys-- Returns:
- A set with members of the resulting set
-
sdiffstore
This command works exactly likeSDIFFbut instead of being returned the resulting set is stored in dstkey.- Specified by:
sdiffstorein interfaceSetCommands- Parameters:
dstkey-keys-- Returns:
- The number of elements in the resulting set
-
srandmember
Return a random element from a Set, without removing the element. If the Set is empty or the key does not exist, a nil object is returned.The SPOP command does a similar work but the returned element is popped (removed) from the Set.
Time complexity O(1)
- Specified by:
srandmemberin interfaceSetCommands- Parameters:
key-- Returns:
- The randomly selected element
-
srandmember
Return a random elements from a Set, without removing the elements. If the Set is empty or the key does not exist, an empty list is returned.The SPOP command does a similar work but the returned elements is popped (removed) from the Set.
Time complexity O(1)
- Specified by:
srandmemberin interfaceSetCommands- Parameters:
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 times- Returns:
- A list of randomly selected elements
-
zadd
Add the specified member having the specified score to the sorted set stored at key. If member is already a member of the sorted set the score is updated, and the element reinserted in the right position to ensure sorting. If key does not exist a new sorted set with the specified member as sole member is created. If the key exists but does not hold a sorted set value an error is returned.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
- Specified by:
zaddin interfaceSortedSetCommands- Parameters:
key-score-member-- Returns:
- 1 if the new element was added, 0 if the element was already a member of the sorted set and the score was updated
-
zadd
Description copied from interface:SortedSetCommandsSimilar toZADDbut can be used with optional params.- Specified by:
zaddin interfaceSortedSetCommands- Parameters:
key-score-member-params-ZAddParams- Returns:
- 1 if the new element was added, 0 if the element was already a member of the sorted set and the score was updated
- See Also:
-
zadd
Description copied from interface:SortedSetCommandsSimilar toZADDbut for multiple members.- Specified by:
zaddin interfaceSortedSetCommands- Parameters:
key-scoreMembers-- Returns:
- The number of elements added to the sorted set (excluding score updates).
- See Also:
-
zadd
Description copied from interface:SortedSetCommandsSimilar toZADDbut can be used with optional params, and fits for multiple members.- Specified by:
zaddin interfaceSortedSetCommands- Parameters:
key-scoreMembers-params-ZAddParams- Returns:
- The number of elements added to the sorted set (excluding score updates).
- See Also:
-
zaddIncr
Description copied from interface:SortedSetCommandsIncrements the score of member in the sorted set stored at key by increment. If member does not exist in the sorted set, it is added with increment as its score (as if its previous score was 0.0). If key does not exist, a new sorted set with the specified member as its sole member is created.The score value should be the string representation of a numeric value, and accepts double precision floating point numbers. It is possible to provide a negative value to decrement the score.
Time complexity O(log(N)) with N being the number of elements in the sorted set
- Specified by:
zaddIncrin interfaceSortedSetCommands- Parameters:
key-score-member-params-ZAddParams- Returns:
- 1 if the new element was added, 0 if the element was already a member of the sorted set and the score was updated
-
zdiff
Description copied from interface:SortedSetCommandsCompute the difference between all the sets in the given keys.Time complexity O(L + (N-K)log(N)) worst case where L is the total number of elements in all the sets, N is the size of the first set, and K is the size of the result set.
- Specified by:
zdiffin interfaceSortedSetCommands- Parameters:
keys- group of sets- Returns:
- The result of the difference
-
zdiffWithScores
Description copied from interface:SortedSetCommandsCompute the difference between all the sets in the given keys. Return the result with scores.- Specified by:
zdiffWithScoresin interfaceSortedSetCommands- Parameters:
keys- group of sets- Returns:
- The result of the difference with their scores
-
zdiffStore
Description copied from interface:SortedSetCommandsCompute the difference between all the sets in the given keys. Store the result in dstkey.- Specified by:
zdiffStorein interfaceSortedSetCommands- Parameters:
dstkey-keys- group of sets- Returns:
- The number of elements in the resulting sorted set at dstkey.
-
zrange
Description copied from interface:SortedSetCommandsReturns the specified range of elements in the sorted set stored at key.Time complexity O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.
- Specified by:
zrangein interfaceSortedSetCommands- Parameters:
key- the key to querystart- the minimum indexstop- the maximum index- Returns:
- A List of Strings in the specified range
-
zrem
Remove the specified member from the sorted set value stored at key. If member was not a member of the set no operation is performed. If key does not hold a set value an error is returned.Time complexity O(log(N)) with N being the number of elements in the sorted set
- Specified by:
zremin interfaceSortedSetCommands- Parameters:
key-members-- Returns:
- 1 if the new element was removed, 0 if the new element was not a member of the set
-
zincrby
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. If member does not already exist in the sorted set it is added with increment as score (that is, like if the previous score was virtually zero). If key does not exist a new sorted set with the specified member as sole member is created. If the key exists but does not hold a sorted set value an error is returned.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
- Specified by:
zincrbyin interfaceSortedSetCommands- Parameters:
key-increment-member-- Returns:
- The new score
-
zincrby
Description copied from interface:SortedSetCommandsSimilar toZINCRBYbut can be used with optionals params.- Specified by:
zincrbyin interfaceSortedSetCommands- Parameters:
key-increment-member-params-ZIncrByParams- Returns:
- The new score for key
- See Also:
-
zrank
Return the rank (or index) of member in the sorted set at key, with scores being ordered from low to high.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))
- Specified by:
zrankin interfaceSortedSetCommands- Parameters:
key-member-- Returns:
- The element as an integer if the element exists. A 'nil' bulk reply if there is no such element.
- See Also:
-
zrevrank
Return the rank (or index) of member in the sorted set at key, with scores being ordered from high to low.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))
- Specified by:
zrevrankin interfaceSortedSetCommands- Parameters:
key-member-- Returns:
- The element as an integer if the element exists. A 'nil' bulk reply if there is no such element.
- See Also:
-
zrankWithScore
Returns the rank and the score of member in the sorted set stored at key, with the scores ordered from low to high.- Specified by:
zrankWithScorein interfaceSortedSetCommands- Parameters:
key- the keymember- the member- Returns:
- the KeyValue contains rank and score.
-
zrevrankWithScore
Returns the rank and the score of member in the sorted set stored at key, with the scores ordered from high to low.- Specified by:
zrevrankWithScorein interfaceSortedSetCommands- Parameters:
key- the keymember- the member- Returns:
- the KeyValue contains rank and score.
-
zrevrange
Description copied from interface:SortedSetCommandsReturns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with equal score.Time complexity O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.
- Specified by:
zrevrangein interfaceSortedSetCommands- Parameters:
key- the key to querystart- the minimum indexstop- the maximum index- Returns:
- A List of Strings in the specified range
-
zrangeWithScores
Description copied from interface:SortedSetCommandsReturns the specified range of elements in the sorted set stored at key with the scores.- Specified by:
zrangeWithScoresin interfaceSortedSetCommands- Parameters:
key- the key to querystart- the minimum indexstop- the maximum index- Returns:
- A List of Tuple in the specified range (elements names and their scores)
-
zrevrangeWithScores
Description copied from interface:SortedSetCommandsSimilar toZREVRANGEbut the reply will include the scores of the returned elements.- Specified by:
zrevrangeWithScoresin interfaceSortedSetCommands- Parameters:
key- the key to querystart- the minimum indexstop- the maximum index- Returns:
- A List of Tuple in the specified range (elements names and their scores)
- See Also:
-
zrange
Description copied from interface:SortedSetCommandsSimilar toZRANGEbut can be used with additional params.- Specified by:
zrangein interfaceSortedSetCommands- Parameters:
key- the key to queryzRangeParams-ZRangeParams- Returns:
- A List of Strings in the specified range
- See Also:
-
zrangeWithScores
Description copied from interface:SortedSetCommandsSimilar toZRANGEbut can be used with additional params.- Specified by:
zrangeWithScoresin interfaceSortedSetCommands- Parameters:
key- the key to queryzRangeParams-ZRangeParams- Returns:
- A List of Tuple in the specified range (elements names and their scores)
- See Also:
-
zrangestore
Description copied from interface:SortedSetCommandsSimilar toZRANGEbut stores the result indest.- Specified by:
zrangestorein interfaceSortedSetCommands- Parameters:
dest- the storing keysrc- the key to queryzRangeParams-ZRangeParams- Returns:
- The number of elements in the resulting sorted set
- See Also:
-
zrandmember
Description copied from interface:SortedSetCommandsReturn a random element from the sorted set value stored at key.Time complexity O(N) where N is the number of elements returned
- Specified by:
zrandmemberin interfaceSortedSetCommands- Parameters:
key-- Returns:
- Random String from the set
-
zrandmember
Description copied from interface:SortedSetCommandsReturn an array of distinct elements. The array's length is either count or the sorted set's cardinality (ZCARD), whichever is lower.Time complexity O(N) where N is the number of elements returned
- Specified by:
zrandmemberin interfaceSortedSetCommands- Parameters:
key-count- choose up to count elements- Returns:
- A list of distinct Strings from the set
-
zrandmemberWithScores
Description copied from interface:SortedSetCommandsSimilar toZRANDMEMBERbut the replay will include the scores with the result.- Specified by:
zrandmemberWithScoresin interfaceSortedSetCommands- Parameters:
key-count- choose up to count elements- Returns:
- A List of distinct Strings with their scores
- See Also:
-
zcard
Return the sorted set cardinality (number of elements). If the key does not exist 0 is returned, like for empty sorted sets.Time complexity O(1)
- Specified by:
zcardin interfaceSortedSetCommands- Parameters:
key-- Returns:
- The cardinality (number of elements) of the set as an integer
-
zscore
Return the score of the specified element of the sorted set at key. If the specified element does not exist in the sorted set, or the key does not exist at all, a special 'nil' value is returned.Time complexity: O(1)
- Specified by:
zscorein interfaceSortedSetCommands- Parameters:
key-member-- Returns:
- The score
-
zmscore
Returns the scores associated with the specified members in the sorted set stored at key. For every member that does not exist in the sorted set, a nil value is returned.Time complexity: O(N) where N is the number of members being requested.
- Specified by:
zmscorein interfaceSortedSetCommands- Parameters:
key-members-- Returns:
- The scores
-
zpopmax
Description copied from interface:SortedSetCommandsRemove and return the member with the highest score in the sorted set stored at key.Time complexity O(log(N)) with N being the number of elements in the sorted set
- Specified by:
zpopmaxin interfaceSortedSetCommands- Parameters:
key-- Returns:
- The popped element and the score
-
zpopmax
Description copied from interface:SortedSetCommandsRemove and return up to count members with the highest scores in the sorted set stored at key.Time complexity O(log(N)*M) with N being the number of elements in the sorted set, and M being the number of elements popped.
- Specified by:
zpopmaxin interfaceSortedSetCommands- Parameters:
key-count- the number of elements to pop- Returns:
- A List of popped elements and scores
-
zpopmin
Description copied from interface:SortedSetCommandsRemove and return the member with the lowest score in the sorted set stored at key.Time complexity O(log(N)) with N being the number of elements in the sorted set
- Specified by:
zpopminin interfaceSortedSetCommands- Parameters:
key-- Returns:
- The popped element and the score
-
zpopmin
Description copied from interface:SortedSetCommandsRemove and return up to count members with the lowest scores in the sorted set stored at key.Time complexity O(log(N)*M) with N being the number of elements in the sorted set, and M being the number of elements popped.
- Specified by:
zpopminin interfaceSortedSetCommands- Parameters:
key-count- the number of elements to pop- Returns:
- A List of popped elements and scores
-
watch
-
sort
Sort a Set or a List.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.
- Specified by:
sortin interfaceKeyCommands- Parameters:
key-- Returns:
- Assuming the Set/List at key contains a list of numbers, the return value will be the list of numbers ordered from the smallest to the biggest number.
- See Also:
-
sort
Sort a Set or a List accordingly to the specified parameters.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 = 7
Sort 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]
- Specified by:
sortin interfaceKeyCommands- Parameters:
key-sortingParams-- Returns:
- a list of sorted elements.
- See Also:
-
sort
Sort a Set or a List accordingly to the specified parameters and store the result at dstkey.- Specified by:
sortin interfaceKeyCommands- Parameters:
key-sortingParams-dstkey-- Returns:
- The number of elements of the list at dstkey
- See Also:
-
sortReadonly
Description copied from interface:KeyCommandsRead-only variant of theSORTcommand. It is exactly like the original SORT but refuses the STORE option and can safely be used in read-only replicas.- Specified by:
sortReadonlyin interfaceKeyCommands- Parameters:
key- the key to sortsortingParams-SortingParams- Returns:
- list of sorted elements.
-
sort
Sort a Set or a List and Store the Result at 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.
- Specified by:
sortin interfaceKeyCommands- Parameters:
key-dstkey-- Returns:
- The number of elements of the list at dstkey
- See Also:
-
lmove
Description copied from interface:ListCommandsPop an element from a list, push it to another list and return it- Specified by:
lmovein interfaceListCommands- Parameters:
srcKey-dstKey-from- can be LEFT or RIGHTto- can be LEFT or RIGHT- Returns:
- The element being popped and pushed
-
blmove
public String blmove(String srcKey, String dstKey, ListDirection from, ListDirection to, double timeout) Description copied from interface:ListCommandsPop an element from a list, push it to another list and return it; or block until one is available- Specified by:
blmovein interfaceListCommands- Parameters:
srcKey-dstKey-from- can be LEFT or RIGHTto- can be LEFT or RIGHTtimeout- the timeout argument is interpreted as a double value specifying the maximum number of seconds to block. A timeout of zero can be used to block indefinitely.- Returns:
- The element being popped and pushed
-
blpop
BLPOP (and BRPOP) is a blocking list pop primitive. You can see this commands as blocking versions of LPOP and RPOP able to block if the specified keys don't exist or contain empty lists.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)
- Specified by:
blpopin interfaceListCommands- Parameters:
timeout-keys-- Returns:
- BLPOP returns a two-elements array via a multi bulk reply in order to return both the
unblocking key and the popped value.
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.
- See Also:
-
blpop
Description copied from interface:ListCommandsThe blocking version ofListCommands.lpop(String)LPOP} because it blocks the connection when there are no elements to pop from any of the given lists. An element is popped from the head of the first list that is non-empty, with the given keys being checked in the order that they are given.- Specified by:
blpopin interfaceListCommands- Parameters:
timeout- the timeout argument is interpreted as a double value specifying the maximum number of seconds to block. A timeout of zero can be used to block indefinitely.keys-
-
brpop
BLPOP (and BRPOP) is a blocking list pop primitive. You can see this commands as blocking versions of LPOP and RPOP able to block if the specified keys don't exist or contain empty lists.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)
- Specified by:
brpopin interfaceListCommands- Parameters:
timeout-keys-- Returns:
- BLPOP returns a two-elements array via a multi bulk reply in order to return both the
unblocking key and the popped value.
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.
- See Also:
-
brpop
Description copied from interface:ListCommandsThe blocking version ofListCommands.rpop(String)RPOP} because it blocks the connection when there are no elements to pop from any of the given lists. An element is popped from the tail of the first list that is non-empty, with the given keys being checked in the order that they are given.- Specified by:
brpopin interfaceListCommands- Parameters:
timeout- the timeout argument is interpreted as a double value specifying the maximum number of seconds to block. A timeout of zero can be used to block indefinitely.keys-
-
lmpop
- Specified by:
lmpopin interfaceListCommands
-
lmpop
- Specified by:
lmpopin interfaceListCommands
-
blmpop
- Specified by:
blmpopin interfaceListCommands
-
blmpop
public KeyValue<String,List<String>> blmpop(long timeout, ListDirection direction, int count, String... keys) - Specified by:
blmpopin interfaceListCommands
-
bzpopmax
Description copied from interface:SortedSetCommandsThe blocking version ofZPOPMAX- Specified by:
bzpopmaxin interfaceSortedSetCommands- Parameters:
timeout- specifying the maximum number of seconds to block. A timeout of zero can be used to block indefinitely.keys-
-
bzpopmin
Description copied from interface:SortedSetCommandsThe blocking version ofZPOPMIN- Specified by:
bzpopminin interfaceSortedSetCommands- Parameters:
timeout- specifying the maximum number of seconds to block. A timeout of zero can be used to block indefinitely.keys-
-
blpop
- Specified by:
blpopin interfaceListCommands- See Also:
-
blpop
- Specified by:
blpopin interfaceListCommands- See Also:
-
brpop
- Specified by:
brpopin interfaceListCommands- See Also:
-
brpop
- Specified by:
brpopin interfaceListCommands- See Also:
-
zcount
Description copied from interface:SortedSetCommandsReturn the number of elements in the sorted set at key with a score between min and max.Time complexity O(log(N)) with N being the number of elements in the sorted set.
- Specified by:
zcountin interfaceSortedSetCommands- Parameters:
key- the key to querymin- minimum scoremax- maximum score- Returns:
- The number of elements in the specified score range.
-
zcount
Description copied from interface:SortedSetCommandsSimilar toZCOUNTbut with exclusive range.- Specified by:
zcountin interfaceSortedSetCommands- See Also:
-
zrangeByScore
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).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
LIMITit is 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
ZCOUNTcommand is similar toZRANGEBYSCOREbut 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 is possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10Will 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))
- Specified by:
zrangeByScorein interfaceSortedSetCommands- Parameters:
key-min- a double or Double.NEGATIVE_INFINITY for "-inf"max- a double or Double.POSITIVE_INFINITY for "+inf"- Returns:
- A list of elements in the specified score range
- See Also:
-
zrangeByScore
Description copied from interface:SortedSetCommandsSimilar toZRANGEbut with exclusive range.- Specified by:
zrangeByScorein interfaceSortedSetCommands- See Also:
-
zrangeByScore
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).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
LIMITit is 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
ZCOUNTcommand is similar toZRANGEBYSCOREbut 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 is possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10Will 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))
- Specified by:
zrangeByScorein interfaceSortedSetCommands- Parameters:
key-min-max-offset-count-- Returns:
- A list of elements in the specified score range
- See Also:
-
zrangeByScore
Description copied from interface:SortedSetCommandsSimilar toZRANGEbut with limit option,- Specified by:
zrangeByScorein interfaceSortedSetCommands- Parameters:
key- the key to querymin- minimum scoremax- maximum scoreoffset- the first index of the sub-rangecount- count of the sub-range. A negative count returns all elements from the offset- Returns:
- A List of elements in the specified score range
- See Also:
-
zrangeByScoreWithScores
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).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
LIMITit is 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
ZCOUNTcommand is similar toZRANGEBYSCOREbut 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 is possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10Will 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))
- Specified by:
zrangeByScoreWithScoresin interfaceSortedSetCommands- Parameters:
key-min-max-- Returns:
- A list of elements in the specified score range
- See Also:
-
zrangeByScoreWithScores
Description copied from interface:SortedSetCommandsSimilar toZRANGEbut with exclusive range, and return with scores.- Specified by:
zrangeByScoreWithScoresin interfaceSortedSetCommands- See Also:
-
zrangeByScoreWithScores
public 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).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
LIMITit is 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
ZCOUNTcommand is similar toZRANGEBYSCOREbut 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 is possible to specify open intervals prefixing the score with a "(" character, so for instance:
ZRANGEBYSCORE zset (1.3 5Will return all the values with score > 1.3 and <= 5, while for instance:
ZRANGEBYSCORE zset (5 (10Will 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))
- Specified by:
zrangeByScoreWithScoresin interfaceSortedSetCommands- Parameters:
key-min-max-offset-count-- Returns:
- A list of elements in the specified score range
- See Also:
-
zrangeByScoreWithScores
public List<Tuple> zrangeByScoreWithScores(String key, String min, String max, int offset, int count) Description copied from interface:SortedSetCommandsSimilar toZRANGEbut with exclusive range, with limit options and return with scores.- Specified by:
zrangeByScoreWithScoresin interfaceSortedSetCommands- Parameters:
key- the key to querymin- minimum scoremax- maximum scoreoffset- the first index of the sub-rangecount- count of the sub-range. A negative count returns all elements from the offset- Returns:
- A List of elements in the specified score range
- See Also:
-
zrevrangeByScore
Description copied from interface:SortedSetCommandsReturn all the elements in the sorted set at key with a score between max and min (including elements with score equal to max or min). In contrary to the default ordering of sorted sets, for this command the elements are considered to be ordered from high to low scores.The elements having the same score are returned in reverse lexicographical order.
Time complexity O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned.
- Specified by:
zrevrangeByScorein interfaceSortedSetCommands- Parameters:
key- the key to querymax- maximum scoremin- minimum score- Returns:
- A List of elements in the specified score range
-
zrevrangeByScore
Description copied from interface:SortedSetCommandsSimilar toZREVRANGEbut with exclusive range.- Specified by:
zrevrangeByScorein interfaceSortedSetCommands- See Also:
-
zrevrangeByScore
Description copied from interface:SortedSetCommandsSimilar toZRANGEbut with limit option,- Specified by:
zrevrangeByScorein interfaceSortedSetCommands- Parameters:
key- the key to querymax- maximum scoremin- minimum scoreoffset- the first index of the sub-rangecount- count of the sub-range. A negative count returns all elements from the offset- Returns:
- A List of elements in the specified score range
- See Also:
-
zrevrangeByScoreWithScores
Description copied from interface:SortedSetCommandsSimilar toZREVRANGEbut return with scores.- Specified by:
zrevrangeByScoreWithScoresin interfaceSortedSetCommands- Parameters:
key- the key to querymax- maximum scoremin- minimum score- Returns:
- A List of elements with scores in the specified score range
- See Also:
-
zrevrangeByScoreWithScores
public List<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) Description copied from interface:SortedSetCommandsSimilar toZREVRANGEbut with limit options and return with scores.- Specified by:
zrevrangeByScoreWithScoresin interfaceSortedSetCommands- Parameters:
key- the key to querymax- maximum scoremin- minimum scoreoffset- the first index of the sub-rangecount- count of the sub-range. A negative count returns all elements from the offset- Returns:
- A List of elements in the specified score range
- See Also:
-
zrevrangeByScoreWithScores
public List<Tuple> zrevrangeByScoreWithScores(String key, String max, String min, int offset, int count) Description copied from interface:SortedSetCommandsSimilar toZREVRANGEbut with exclusive range, with limit options and return with scores.- Specified by:
zrevrangeByScoreWithScoresin interfaceSortedSetCommands- Parameters:
key- the key to querymax- maximum scoremin- minimum scoreoffset- the first index of the sub-rangecount- count of the sub-range. A negative count returns all elements from the offset- Returns:
- A List of elements in the specified score range
- See Also:
-
zrevrangeByScore
Description copied from interface:SortedSetCommandsSimilar toZREVRANGEbut with limit option,- Specified by:
zrevrangeByScorein interfaceSortedSetCommands- Parameters:
key- the key to querymax- maximum scoremin- minimum scoreoffset- the first index of the sub-rangecount- count of the sub-range. A negative count returns all elements from the offset- Returns:
- A List of elements in the specified score range
- See Also:
-
zrevrangeByScoreWithScores
Description copied from interface:SortedSetCommandsSimilar toZREVRANGEbut with exclusive range, and return with scores.- Specified by:
zrevrangeByScoreWithScoresin interfaceSortedSetCommands- See Also:
-
zremrangeByRank
Remove all elements in the sorted set at key with rank between start and end. Start and end are 0-based with rank 0 being the element with the lowest score. Both start and end can be negative numbers, where they indicate offsets starting at the element with the highest rank. For example: -1 is the element with the highest score, -2 the element with the second highest score and so forth.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
- Specified by:
zremrangeByRankin interfaceSortedSetCommands- Parameters:
key-start-stop-- Returns:
- The number of elements removed
-
zremrangeByScore
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).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
- Specified by:
zremrangeByScorein interfaceSortedSetCommands- Parameters:
key-min-max-- Returns:
- The number of elements removed
-
zremrangeByScore
Description copied from interface:SortedSetCommandsSimilar toZREMRANGEbut with limit option.- Specified by:
zremrangeByScorein interfaceSortedSetCommands- See Also:
-
zunion
Add multiple sorted sets, This command is similar to ZUNIONSTORE, but instead of storing the resulting sorted set, it is returned to the connection.- Specified by:
zunionin interfaceSortedSetCommands- Parameters:
params-keys-- Returns:
- A set with members of the resulting set
-
zunionWithScores
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.- Specified by:
zunionWithScoresin interfaceSortedSetCommands- Parameters:
params-keys-- Returns:
- A set with members of the resulting set with scores
-
zunionstore
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. It is mandatory to provide the number of input keys N, before passing the input keys and the other (optional) arguments.As the terms imply, the
ZINTERSTOREcommand requires an element to be present in each of the given inputs to be inserted in the result. TheZUNIONSTOREcommand 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 is 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
- Specified by:
zunionstorein interfaceSortedSetCommands- Parameters:
dstkey-sets-- Returns:
- The number of elements in the sorted set at dstkey
- See Also:
-
zunionstore
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. It is mandatory to provide the number of input keys N, before passing the input keys and the other (optional) arguments.As the terms imply, the
ZINTERSTOREcommand requires an element to be present in each of the given inputs to be inserted in the result. TheZUNIONSTOREcommand 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 is 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
- Specified by:
zunionstorein interfaceSortedSetCommands- Parameters:
dstkey-params-sets-- Returns:
- The number of elements in the sorted set at dstkey
- See Also:
-
zinter
Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the connection.- Specified by:
zinterin interfaceSortedSetCommands- Parameters:
params-keys-- Returns:
- A set with members of the resulting set
-
zinterWithScores
Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the connection.- Specified by:
zinterWithScoresin interfaceSortedSetCommands- Parameters:
params-keys-- Returns:
- A set with members of the resulting set with scores
-
zintercard
Description copied from interface:SortedSetCommandsSimilar toZINTER, but instead of returning the result set, it returns just the cardinality of the result.Time complexity O(N*K) worst case with N being the smallest input sorted set, K being the number of input sorted sets
- Specified by:
zintercardin interfaceSortedSetCommands- Parameters:
keys- group of sets- Returns:
- The number of elements in the resulting intersection
- See Also:
-
zintercard
Description copied from interface:SortedSetCommandsSimilar toZINTER, but instead of returning the result set, it returns just the cardinality of the result.Time complexity O(N*K) worst case with N being the smallest input sorted set, K being the number of input sorted sets
- Specified by:
zintercardin interfaceSortedSetCommands- Parameters:
limit- If the intersection cardinality reaches limit partway through the computation, the algorithm will exit and yield limit as the cardinalitykeys- group of sets- Returns:
- The number of elements in the resulting intersection
- See Also:
-
zinterstore
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. It is mandatory to provide the number of input keys N, before passing the input keys and the other (optional) arguments.As the terms imply, the
ZINTERSTOREcommand requires an element to be present in each of the given inputs to be inserted in the result. TheZUNIONSTOREcommand 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 is 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
- Specified by:
zinterstorein interfaceSortedSetCommands- Parameters:
dstkey-sets-- Returns:
- The number of elements in the sorted set at dstkey
- See Also:
-
zinterstore
Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. It is mandatory to provide the number of input keys N, before passing the input keys and the other (optional) arguments.As the terms imply, the
ZINTERSTOREcommand requires an element to be present in each of the given inputs to be inserted in the result. TheZUNIONSTOREcommand 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 is 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
- Specified by:
zinterstorein interfaceSortedSetCommands- Parameters:
dstkey-params-sets-- Returns:
- The number of elements in the sorted set at dstkey
- See Also:
-
zlexcount
Description copied from interface:SortedSetCommandsReturn the number of elements in the sorted set at key with a value between min and max, when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.Time complexity O(log(N)) with N being the number of elements in the sorted set.
- Specified by:
zlexcountin interfaceSortedSetCommands- Parameters:
key-min- minimum valuemax- maximum value- Returns:
- The number of elements in the specified score range
-
zrangeByLex
Description copied from interface:SortedSetCommandsReturn all the elements in the sorted set at key with a value between min and max, when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.Time complexity O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned.
- Specified by:
zrangeByLexin interfaceSortedSetCommands- Parameters:
key-min- minimum valuemax- maximum value- Returns:
- A List of elements in the specified score range
-
zrangeByLex
Description copied from interface:SortedSetCommandsSimilar toZRANGEbut with limit option.- Specified by:
zrangeByLexin interfaceSortedSetCommands- Parameters:
key-min- minimum valuemax- maximum valueoffset- the first index of the sub-rangecount- count of the sub-range. A negative count returns all elements from the offset- Returns:
- A List of elements in the specified score range
- See Also:
-
zrevrangeByLex
Description copied from interface:SortedSetCommandsReturn all the elements in the sorted set at key with a value between max and min, when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.Time complexity O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned.
- Specified by:
zrevrangeByLexin interfaceSortedSetCommands- Parameters:
key-max- maximum valuemin- minimum value- Returns:
- A List of elements in the specified score range
-
zrevrangeByLex
Description copied from interface:SortedSetCommandsSimilar toZRANGEbut with limit option.- Specified by:
zrevrangeByLexin interfaceSortedSetCommands- Parameters:
key-max- maximum valuemin- minimum valueoffset- the first index of the sub-rangecount- count of the sub-range. A negative count returns all elements from the offset- Returns:
- A List of elements in the specified score range
- See Also:
-
zremrangeByLex
Description copied from interface:SortedSetCommandsRemove all elements in the sorted set stored at key between the lexicographical range specified by min and max, when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.Time complexity O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements removed by the operation.
- Specified by:
zremrangeByLexin interfaceSortedSetCommands- Parameters:
key-min- minimum value to removemax- maximum value to remove- Returns:
- The number of elements removed
-
zmpop
- Specified by:
zmpopin interfaceSortedSetCommands
-
zmpop
- Specified by:
zmpopin interfaceSortedSetCommands
-
bzmpop
- Specified by:
bzmpopin interfaceSortedSetCommands
-
bzmpop
public KeyValue<String,List<Tuple>> bzmpop(long timeout, SortedSetOption option, int count, String... keys) - Specified by:
bzmpopin interfaceSortedSetCommands
-
strlen
Description copied from interface:StringCommandsStrLen Command Return the length of the string value stored at key.- Specified by:
strlenin interfaceStringCommands- Parameters:
key-- Returns:
- The length of the string at key, or 0 when key does not exist
-
strAlgoLCSKeys
Deprecated.STRALGO LCS command will be removed from Redis 7.LCScan be used instead of this method.Calculate the longest common subsequence of keyA and keyB.- Specified by:
strAlgoLCSKeysin interfaceStringCommands- Parameters:
keyA-keyB-params-- Returns:
- According to StrAlgoLCSParams to decide to return content to fill LCSMatchResult.
-
strAlgoLCSStrings
@Deprecated public LCSMatchResult strAlgoLCSStrings(String strA, String strB, StrAlgoLCSParams params) Deprecated.STRALGO LCS command will be removed from Redis 7.Calculate the longest common subsequence of strA and strB.- Parameters:
strA-strB-params-- Returns:
- According to StrAlgoLCSParams to decide to return content to fill LCSMatchResult.
-
lcs
Calculate the longest common subsequence of keyA and keyB.- Specified by:
lcsin interfaceStringCommands- Parameters:
keyA-keyB-params-- Returns:
- According to LCSParams to decide to return content to fill LCSMatchResult.
-
lpushx
Description copied from interface:ListCommandsInserts specified values at the head of the list stored at key. In contrary toLPUSH, no operation will be performed when key does not yet exist.- Specified by:
lpushxin interfaceListCommands- Parameters:
key-strings- the strings to push- Returns:
- The length of the list after the push operation
-
persist
Undo aexpireat turning the expire key into a normal key.Time complexity: O(1)
- Specified by:
persistin interfaceKeyCommands- Parameters:
key-- Returns:
- 1 if the key is now persist, 0 if the key is not persist (only happens when key not set)
-
rpushx
Description copied from interface:ListCommandsInserts specified values at the tail of the list stored at key. In contrary toRPUSH, no operation will be performed when key does not yet exist.- Specified by:
rpushxin interfaceListCommands- Parameters:
key-strings- the strings to push- Returns:
- The length of the list after the push operation
-
echo
- Specified by:
echoin interfaceServerCommands
-
linsert
Description copied from interface:ListCommandsInserts element in the list stored at key either before or after the reference value pivot.When key does not exist, it is considered an empty list and no operation is performed.
- Specified by:
linsertin interfaceListCommands- Parameters:
key-where- can be BEFORE or AFTERpivot- reference valuevalue- the value- Returns:
- The length of the list after the insert operation, or -1 when the value pivot was not found
-
brpoplpush
Pop a value from a list, push it to another list and return it; or block until one is available- Specified by:
brpoplpushin interfaceListCommands- Parameters:
source-destination-timeout-- Returns:
- The element
-
setbit
Sets or clears the bit at offset in the string value stored at key- Specified by:
setbitin interfaceBitCommands- Parameters:
key-offset-value-- Returns:
- The original bit value stored at offset
-
getbit
Returns the bit value at offset in the string value stored at key- Specified by:
getbitin interfaceBitCommands- Parameters:
key-offset-- Returns:
- The bit value stored at offset
-
setrange
Description copied from interface:StringCommandsSetRange Command GETRANGE overwrite part of the string stored at key, starting at the specified offset, for the entire length of value. If the offset is larger than the current length of the string at key, the string is padded with zero-bytes to make offset fit. Non-existing keys are considered as empty strings, so this command will make sure it holds a string large enough to be able to set value at offset.Time complexity: O(1)
- Specified by:
setrangein interfaceStringCommands- Parameters:
key-offset-value-- Returns:
- The length of the string after it was modified by the command
-
getrange
Description copied from interface:StringCommandsGetRange Command Return the substring of the string value stored at key, determined by the offsets start and end (both are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the string. So -1 means the last character, -2 the penultimate and so forth.Time complexity: O(N) where N is the length of the returned string
- Specified by:
getrangein interfaceStringCommands- Parameters:
key-startOffset-endOffset-- Returns:
- The substring
-
bitpos
Description copied from interface:BitCommandsBitpos Command Return the position of the first bit set to 1 or 0 in a string.- Specified by:
bitposin interfaceBitCommands- Parameters:
key-value- the bit value- Returns:
- The position of the first bit set to 1 or 0 according to the request
-
bitpos
Description copied from interface:BitCommandsBitpos Command Return the position of the first bit set to 1 or 0 in a string.- Specified by:
bitposin interfaceBitCommands- Parameters:
key-value- the bit valueparams-BitPosParams- Returns:
- The position of the first bit set to 1 or 0 according to the request
-
role
Description copied from interface:ControlCommandsProvide information on the role of a Redis instance in the context of replication, by returning if the instance is currently a master, slave, or sentinel. The command also returns additional information about the state of the replication (if the role is master or slave) or the list of monitored master names (if the role is sentinel).- Specified by:
rolein interfaceControlCommands- Returns:
- The information on the role of a Redis instance
-
configGet
Retrieve the configuration of a running Redis server. Not all the configuration parameters are supported.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"
- Specified by:
configGetin interfaceConfigCommands- Parameters:
pattern-- Returns:
- Bulk reply.
-
configGet
Description copied from interface:ConfigCommandsUsed to read the configuration parameters of Redis server.- Specified by:
configGetin interfaceConfigCommands- Parameters:
patterns- names of Redis server's configuration- Returns:
- values of Redis server's configuration
-
configSet
Alter the configuration of a running Redis server. Not all the configuration parameters are supported.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:
- The save parameter is a list of space-separated integers. Every pair of integers specify the time and number of changes limit to trigger a save. For instance the command CONFIG SET save "3600 10 60 10000" will configure the server to issue a background saving of the RDB file every 3600 seconds if there are at least 10 changes in the dataset, and every 60 seconds if there are at least 10000 changes. To completely disable automatic snapshots just set the parameter as an empty string.
- All the integer parameters representing memory are returned and accepted only using bytes as unit.
- Specified by:
configSetin interfaceConfigCommands- Parameters:
parameter-value-- Returns:
- OK
-
configSet
- Specified by:
configSetin interfaceConfigCommands
-
publish
-
subscribe
-
psubscribe
-
pubsubChannels
-
pubsubChannels
-
pubsubNumPat
-
pubsubNumSub
-
eval
Description copied from interface:ScriptingKeyCommandsEval Command Use to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.- Specified by:
evalin interfaceScriptingKeyCommands- Parameters:
script- Lua 5.1 script. The script does not need to define a Lua function (and should not). It is just a Lua program that will run in the context of the Redis server.keyCount- the count of the provided keysparams- arguments that can be accessed from the script- Returns:
- The result of the evaluated script
-
eval
Description copied from interface:ScriptingKeyCommandsEval Command Use to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.- Specified by:
evalin interfaceScriptingKeyCommands- Parameters:
script- Lua 5.1 script. The script does not need to define a Lua function (and should not). It is just a Lua program that will run in the context of the Redis server.keys- arguments that can be accessed by the scriptargs- additional arguments should not represent key names and can be accessed by the script- Returns:
- The result of the evaluated script
-
evalReadonly
Description copied from interface:ScriptingKeyCommandsReadonly version ofEVAL- Specified by:
evalReadonlyin interfaceScriptingKeyCommands- Parameters:
script- Lua 5.1 script. The script does not need to define a Lua function (and should not). It is just a Lua program that will run in the context of the Redis server.keys- arguments that can be accessed by the scriptargs- additional arguments should not represent key names and can be accessed by the script- Returns:
- The result of the evaluated script
- See Also:
-
eval
Description copied from interface:ScriptingKeyCommandsEval Command Use to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.- Specified by:
evalin interfaceScriptingKeyCommands- Parameters:
script- Lua 5.1 script. The script does not need to define a Lua function (and should not). It is just a Lua program that will run in the context of the Redis server.- Returns:
- The result of the evaluated script
-
evalsha
Description copied from interface:ScriptingKeyCommandsEvalSha Command Similar toEVAL, but the script cached on the server side by its SHA1 digest. Scripts are cached on the server side using the SCRIPT LOAD command.- Specified by:
evalshain interfaceScriptingKeyCommands- Parameters:
sha1- the script- Returns:
- The result of the evaluated script
- See Also:
-
evalsha
Description copied from interface:ScriptingKeyCommandsEvalSha Command Similar toScriptingKeyCommands.eval(String, List, List)EVAL}, but the script cached on the server side by its SHA1 digest. Scripts are cached on the server side using the SCRIPT LOAD command.- Specified by:
evalshain interfaceScriptingKeyCommands- Parameters:
sha1- the script- Returns:
- The result of the evaluated script
- See Also:
-
evalshaReadonly
Description copied from interface:ScriptingKeyCommandsReadonly version ofEVAL- Specified by:
evalshaReadonlyin interfaceScriptingKeyCommands- Parameters:
sha1- the script- Returns:
- The result of the evaluated script
- See Also:
-
evalsha
Description copied from interface:ScriptingKeyCommandsEvalSha Command Similar toScriptingKeyCommands.eval(String, int, String...)EVAL}, but the script cached on the server side by its SHA1 digest. Scripts are cached on the server side using the SCRIPT LOAD command.- Specified by:
evalshain interfaceScriptingKeyCommands- Parameters:
sha1- the script- Returns:
- The result of the evaluated script
- See Also:
-
scriptExists
- Specified by:
scriptExistsin interfaceScriptingControlCommands
-
scriptExists
- Specified by:
scriptExistsin interfaceScriptingControlCommands
-
scriptLoad
- Specified by:
scriptLoadin interfaceScriptingControlCommands
-
slowlogGet
- Specified by:
slowlogGetin interfaceSlowlogCommands
-
slowlogGet
- Specified by:
slowlogGetin interfaceSlowlogCommands
-
objectRefcount
Description copied from interface:KeyCommandsObject Refcount Command Return the reference count of the stored at key.Time complexity: O(1)
- Specified by:
objectRefcountin interfaceControlCommands- Specified by:
objectRefcountin interfaceKeyCommands- Parameters:
key-- Returns:
- The number of references
-
objectEncoding
Description copied from interface:KeyCommandsObject Encoding Command Return the internal encoding for the Redis object stored at key.Time complexity: O(1)
- Specified by:
objectEncodingin interfaceControlCommands- Specified by:
objectEncodingin interfaceKeyCommands- Parameters:
key-- Returns:
- The encoding of the object
-
objectIdletime
Description copied from interface:KeyCommandsObject IdleTime Command Return the time in seconds since the last access to the value stored at key.Time complexity: O(1)
- Specified by:
objectIdletimein interfaceControlCommands- Specified by:
objectIdletimein interfaceKeyCommands- Parameters:
key-- Returns:
- The idle time in seconds
-
objectHelp
Description copied from interface:ControlCommandsReturns the object subcommands and usages.- Specified by:
objectHelpin interfaceControlCommands- Returns:
- object subcommands and usages
-
objectFreq
Description copied from interface:KeyCommandsObject Freq Command Return the logarithmic access frequency counter of a Redis object stored at key.Time complexity: O(1)
- Specified by:
objectFreqin interfaceControlCommands- Specified by:
objectFreqin interfaceKeyCommands- Parameters:
key-- Returns:
- The counter's value
-
bitcount
Description copied from interface:BitCommandsBitcount Command Count the number of set bits (population counting) in a string.- Specified by:
bitcountin interfaceBitCommands- Parameters:
key-- Returns:
- The number of bits set to 1
-
bitcount
Description copied from interface:BitCommandsBitcount Command Count the number of set bits (population counting) in a string only in an interval start and end.Like for the GETRANGE command start and end can contain negative values in order to index bytes starting from the end of the string, where -1 is the last byte, -2 is the penultimate, and so forth.
- Specified by:
bitcountin interfaceBitCommands- Parameters:
key-start- byte start indexend- byte end index- Returns:
- The number of bits set to 1
-
bitcount
- Specified by:
bitcountin interfaceBitCommands- Parameters:
key-start- byte start indexend- byte end indexoption- indicate BYTE or BIT- Returns:
- The number of bits set to 1
- See Also:
-
bitop
Description copied from interface:BitCommandsBitop Command Perform a bitwise operation between multiple keys (containing string values) and store the result in the destKey.- Specified by:
bitopin interfaceBitCommands- Parameters:
op- can be AND, OR, XOR or NOTdestKey-srcKeys-- Returns:
- The size of the string stored in the destKey
-
commandCount
public long commandCount() -
commandDocs
-
commandGetKeys
-
commandGetKeysAndFlags
-
commandInfo
-
commandList
-
commandListFilterBy
-
sentinelMyId
- Specified by:
sentinelMyIdin interfaceSentinelCommands
-
sentinelMasters
redis 127.0.0.1:26381> sentinel masters 1) 1) "name" 2) "mymaster" 3) "ip" 4) "127.0.0.1" 5) "port" 6) "6379" 7) "runid" 8) "93d4d4e6e9c06d0eea36e27f31924ac26576081d" 9) "flags" 10) "master" 11) "pending-commands" 12) "0" 13) "last-ok-ping-reply" 14) "423" 15) "last-ping-reply" 16) "423" 17) "info-refresh" 18) "6107" 19) "num-slaves" 20) "1" 21) "num-other-sentinels" 22) "2" 23) "quorum" 24) "2"- Specified by:
sentinelMastersin interfaceSentinelCommands
-
sentinelMaster
- Specified by:
sentinelMasterin interfaceSentinelCommands
-
sentinelSentinels
- Specified by:
sentinelSentinelsin interfaceSentinelCommands
-
sentinelGetMasterAddrByName
redis 127.0.0.1:26381> sentinel get-master-addr-by-name mymaster 1) "127.0.0.1" 2) "6379"
- Specified by:
sentinelGetMasterAddrByNamein interfaceSentinelCommands- Parameters:
masterName-- Returns:
- two elements list of strings : host and port.
-
sentinelReset
redis 127.0.0.1:26381> sentinel reset mymaster (integer) 1
- Specified by:
sentinelResetin interfaceSentinelCommands- Parameters:
pattern-
-
sentinelSlaves
Deprecated.redis 127.0.0.1:26381> sentinel slaves mymaster 1) 1) "name" 2) "127.0.0.1:6380" 3) "ip" 4) "127.0.0.1" 5) "port" 6) "6380" 7) "runid" 8) "d7f6c0ca7572df9d2f33713df0dbf8c72da7c039" 9) "flags" 10) "slave" 11) "pending-commands" 12) "0" 13) "last-ok-ping-reply" 14) "47" 15) "last-ping-reply" 16) "47" 17) "info-refresh" 18) "657" 19) "master-link-down-time" 20) "0" 21) "master-link-status" 22) "ok" 23) "master-host" 24) "localhost" 25) "master-port" 26) "6379" 27) "slave-priority" 28) "100"- Specified by:
sentinelSlavesin interfaceSentinelCommands- Parameters:
masterName-
-
sentinelReplicas
- Specified by:
sentinelReplicasin interfaceSentinelCommands
-
sentinelFailover
- Specified by:
sentinelFailoverin interfaceSentinelCommands
-
sentinelMonitor
- Specified by:
sentinelMonitorin interfaceSentinelCommands
-
sentinelRemove
- Specified by:
sentinelRemovein interfaceSentinelCommands
-
sentinelSet
- Specified by:
sentinelSetin interfaceSentinelCommands
-
dump
Description copied from interface:KeyCommandsDump Command Serialize the value stored at key in a Redis-specific format and return it to the user.Time complexity: O(1) to access the key and additional O(N*M) to serialize it where N is the number of Redis objects composing the value and M their average size.
- Specified by:
dumpin interfaceKeyCommands- Parameters:
key-- Returns:
- The serialized value
-
restore
Description copied from interface:KeyCommandsRestore Command Create a key associated with a value that is obtained by deserializing the provided serialized value (obtained viaDUMP).Time complexity: O(1) to access the key and additional O(N*M) to serialize it where N is the number of Redis objects composing the value and M their average size.
- Specified by:
restorein interfaceKeyCommands- Parameters:
key-ttl- If ttl is 0 the key is created without any expire, otherwise the specified expire time (in milliseconds) is set.serializedValue-- Returns:
- OK
-
restore
Description copied from interface:KeyCommandsRestore Command Create a key associated with a value that is obtained by deserializing the provided serialized value (obtained viaDUMP).Time complexity: O(1) to access the key and additional O(N*M) to serialize it where N is the number of Redis objects composing the value and M their average size.
- Specified by:
restorein interfaceKeyCommands- Parameters:
key-ttl- If ttl is 0 the key is created without any expire, otherwise the specified expire time (in milliseconds) is set.serializedValue-params-RestoreParams- Returns:
- OK
-
pttl
Description copied from interface:KeyCommandsPTTL Command The PTTL command returns the remaining time to live in milliseconds of a key that has anEXPIREset.Time complexity: O(1)
- Specified by:
pttlin interfaceKeyCommands- Parameters:
key-- Returns:
- TTL in milliseconds, or a negative value in order to signal an error
-
psetex
PSETEX works exactly likesetex(String, long, String)with the sole difference that the expire time is specified in milliseconds instead of seconds. Time complexity: O(1)- Specified by:
psetexin interfaceStringCommands- Parameters:
key-milliseconds-value-- Returns:
- OK
-
aclSetUser
Description copied from interface:AccessControlLogCommandsCreate an ACL for the specified user with the default rules.- Specified by:
aclSetUserin interfaceAccessControlLogCommands- Parameters:
name- user who receives an acl- Returns:
- A string containing OK on success
- See Also:
-
aclSetUser
Description copied from interface:AccessControlLogCommandsCreate an ACL for the specified user, while specifying the rules.- Specified by:
aclSetUserin interfaceAccessControlLogCommands- Parameters:
name- user who receives an aclparams- the acl rules for the specified user- Returns:
- A string containing OK on success
- See Also:
-
aclDelUser
Description copied from interface:AccessControlLogCommandsDelete the specified user, from the ACL.- Specified by:
aclDelUserin interfaceAccessControlLogCommands- Parameters:
name- The username to delete- Returns:
- The number of users delete
- See Also:
-
aclDelUser
Description copied from interface:AccessControlLogCommandsDelete the specified users, from the ACL.- Specified by:
aclDelUserin interfaceAccessControlLogCommands- Parameters:
name- The username to deletenames- Other usernames to delete- Returns:
- The number of users delete
- See Also:
-
aclGetUser
Description copied from interface:AccessControlLogCommandsThe command returns all the rules defined for an existing ACL user.- Specified by:
aclGetUserin interfaceAccessControlLogCommands- Parameters:
name- username- Returns:
- a list of ACL rule definitions for the user.
-
aclUsers
Description copied from interface:AccessControlLogCommandsShows a list of all usernames currently configured with access control lists (ACL).- Specified by:
aclUsersin interfaceAccessControlLogCommands- Returns:
- list of users
- See Also:
-
aclList
Description copied from interface:AccessControlLogCommandsReturns the currently active ACL rules on the Redis Server- Specified by:
aclListin interfaceAccessControlLogCommands- Returns:
- An array of ACL rules
- See Also:
-
aclWhoAmI
Description copied from interface:AccessControlLogCommandsReturns the username used to authenticate the current connection.- Specified by:
aclWhoAmIin interfaceAccessControlLogCommands- Returns:
- The username used for the current connection
- See Also:
-
aclCat
Description copied from interface:AccessControlLogCommandsShow the available ACL categories.- Specified by:
aclCatin interfaceAccessControlLogCommands- Returns:
- the available ACL categories
- See Also:
-
aclCat
Description copied from interface:AccessControlLogCommandsShow the available ACLs for a given category.- Specified by:
aclCatin interfaceAccessControlLogCommands- Parameters:
category- The category for which to list available ACLs- Returns:
- the available ACL categories
- See Also:
-
aclLog
Description copied from interface:AccessControlLogCommandsShows the recent ACL security events.- Specified by:
aclLogin interfaceAccessControlLogCommands- Returns:
- The list of recent security events
- See Also:
-
aclLog
Description copied from interface:AccessControlLogCommandsShows the recent limit ACL security events.- Specified by:
aclLogin interfaceAccessControlLogCommands- Parameters:
limit- The number of results to return- Returns:
- The list of recent security events
- See Also:
-
aclLoad
Description copied from interface:AccessControlLogCommandsThis function tells Redis to reload its external ACL rules, when Redis is configured with an external ACL file- Specified by:
aclLoadin interfaceAccessControlLogBinaryCommands- Specified by:
aclLoadin interfaceAccessControlLogCommands- Returns:
- OK or error text
- See Also:
-
aclSave
Description copied from interface:AccessControlLogCommandsSave the currently defined in-memory ACL to disk.- Specified by:
aclSavein interfaceAccessControlLogBinaryCommands- Specified by:
aclSavein interfaceAccessControlLogCommands- Returns:
- OK on success
- See Also:
-
aclGenPass
Description copied from interface:AccessControlLogCommandsGenerate a random password- Specified by:
aclGenPassin interfaceAccessControlLogCommands- Returns:
- A random password
-
aclGenPass
Description copied from interface:AccessControlLogCommandsGenerate a random password- Specified by:
aclGenPassin interfaceAccessControlLogCommands- Parameters:
bits- the number of output bits- Returns:
- A random password
-
aclDryRun
- Specified by:
aclDryRunin interfaceAccessControlLogCommands
-
aclDryRun
- Specified by:
aclDryRunin interfaceAccessControlLogCommands
-
aclDryRunBinary
public byte[] aclDryRunBinary(byte[] username, byte[] command, byte[]... args) - Specified by:
aclDryRunBinaryin interfaceAccessControlLogBinaryCommands
-
aclDryRunBinary
- Specified by:
aclDryRunBinaryin interfaceAccessControlLogBinaryCommands
-
clientKill
Description copied from interface:ClientCommandsClose a given client connection.- Specified by:
clientKillin interfaceClientCommands- Parameters:
ipPort- The ip:port should match a line returned by the CLIENT LIST command (addr field).- Returns:
- Close success return OK
-
clientGetname
Description copied from interface:ClientCommandsReturns the name of the current connection as set by CLIENT SETNAME- Specified by:
clientGetnamein interfaceClientCommands- Returns:
- Current connect name
-
clientList
Description copied from interface:ClientCommandsReturns information and statistics about the client connections server in a mostly human readable format.- Specified by:
clientListin interfaceClientCommands- Returns:
- All clients info connected to redis-server
-
clientList
Description copied from interface:ClientCommandsReturns information and statistics about the client connections server in a mostly human readable format filter by client type.- Specified by:
clientListin interfaceClientCommands- Returns:
- All clients info connected to redis-server
-
clientList
Description copied from interface:ClientCommandsReturns information and statistics about the client connections server in a mostly human readable format filter by client ids.- Specified by:
clientListin interfaceClientCommands- Parameters:
clientIds- Unique 64-bit client IDs- Returns:
- All clients info connected to redis-server
-
clientInfo
Description copied from interface:ClientCommandsReturns information and statistics about the current client connection in a mostly human readable format.- Specified by:
clientInfoin interfaceClientCommands- Returns:
- Information and statistics about the current client connection
-
clientSetInfo
Description copied from interface:ClientCommandsclient set info command Since redis 7.2- Specified by:
clientSetInfoin interfaceClientCommands- Parameters:
attr- the attr optionvalue- the value- Returns:
- OK or error
-
clientSetname
Description copied from interface:ClientCommandsAssigns a name to the current connection.- Specified by:
clientSetnamein interfaceClientCommands- Parameters:
name- current connection name- Returns:
- OK if the connection name was successfully set.
-
migrate
Description copied from interface:DatabaseCommandsMigrate Command Atomically transfer a key from a source Redis instance to a destination Redis instance. On success the key is deleted from the original instance and is guaranteed to exist in the target instance.- Specified by:
migratein interfaceDatabaseCommands- Parameters:
host- target hostport- target portkey- migrate keydestinationDb- target dbtimeout- the maximum idle time in any moment of the communication with the destination instance in milliseconds.- Returns:
- OK on success, or NOKEY if no keys were found in the source instance
-
migrate
public String migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, String... keys) Description copied from interface:DatabaseCommandsMigrate Command Atomically transfer a key from a source Redis instance to a destination Redis instance. On success the key is deleted from the original instance and is guaranteed to exist in the target instance.- Specified by:
migratein interfaceDatabaseCommands- Parameters:
host- target hostport- target portdestinationDB- target dbtimeout- the maximum idle time in any moment of the communication with the destination instance in milliseconds.params-MigrateParamskeys- to migrate- Returns:
- OK on success, or NOKEY if no keys were found in the source instance.
-
migrate
Description copied from interface:KeyCommandsMigrate Command Atomically transfer a key from a source Redis instance to a destination Redis instance. On success the key is deleted from the original instance and is guaranteed to exist in the target instance.- Specified by:
migratein interfaceKeyCommands- Parameters:
host-port-key-timeout- the maximum idle time in any moment of the communication with the destination instance in milliseconds.- Returns:
- OK on success, or NOKEY if no keys were found in the source instance.
-
migrate
Description copied from interface:KeyCommandsMigrate Command Atomically transfer a key from a source Redis instance to a destination Redis instance. On success the key is deleted from the original instance and is guaranteed to exist in the target instance.- Specified by:
migratein interfaceKeyCommands- Parameters:
host-port-timeout- the maximum idle time in any moment of the communication with the destination instance in milliseconds.params-MigrateParamskeys-- Returns:
- OK on success, or NOKEY if no keys were found in the source instance.
-
scan
- Specified by:
scanin interfaceKeyCommands
-
scan
- Specified by:
scanin interfaceKeyCommands
-
scan
- Specified by:
scanin interfaceKeyCommands
-
hscan
- Specified by:
hscanin interfaceHashCommands
-
sscan
- Specified by:
sscanin interfaceSetCommands
-
zscan
- Specified by:
zscanin interfaceSortedSetCommands
-
readonly
- Specified by:
readonlyin interfaceClusterCommands
-
readwrite
- Specified by:
readwritein interfaceClusterCommands
-
clusterNodes
- Specified by:
clusterNodesin interfaceClusterCommands
-
clusterMeet
- Specified by:
clusterMeetin interfaceClusterCommands
-
clusterReset
- Specified by:
clusterResetin interfaceClusterCommands
-
clusterReset
Description copied from interface:ClusterCommandsresetTypecan be null for default behavior.- Specified by:
clusterResetin interfaceClusterCommands- Parameters:
resetType-- Returns:
- OK
-
clusterAddSlots
- Specified by:
clusterAddSlotsin interfaceClusterCommands
-
clusterDelSlots
- Specified by:
clusterDelSlotsin interfaceClusterCommands
-
clusterInfo
- Specified by:
clusterInfoin interfaceClusterCommands
-
clusterGetKeysInSlot
- Specified by:
clusterGetKeysInSlotin interfaceClusterCommands
-
clusterGetKeysInSlotBinary
- Specified by:
clusterGetKeysInSlotBinaryin interfaceClusterCommands
-
clusterSetSlotNode
- Specified by:
clusterSetSlotNodein interfaceClusterCommands
-
clusterSetSlotMigrating
- Specified by:
clusterSetSlotMigratingin interfaceClusterCommands
-
clusterSetSlotImporting
- Specified by:
clusterSetSlotImportingin interfaceClusterCommands
-
clusterSetSlotStable
- Specified by:
clusterSetSlotStablein interfaceClusterCommands
-
clusterForget
- Specified by:
clusterForgetin interfaceClusterCommands
-
clusterFlushSlots
- Specified by:
clusterFlushSlotsin interfaceClusterCommands
-
clusterKeySlot
- Specified by:
clusterKeySlotin interfaceClusterCommands
-
clusterCountFailureReports
- Specified by:
clusterCountFailureReportsin interfaceClusterCommands
-
clusterCountKeysInSlot
public long clusterCountKeysInSlot(int slot) - Specified by:
clusterCountKeysInSlotin interfaceClusterCommands
-
clusterSaveConfig
- Specified by:
clusterSaveConfigin interfaceClusterCommands
-
clusterSetConfigEpoch
Description copied from interface:ClusterCommandsSet a specific config epoch in a fresh node. It only works when the nodes' table of the node is empty or when the node current config epoch is zero.- Specified by:
clusterSetConfigEpochin interfaceClusterCommands- Parameters:
configEpoch-- Returns:
- OK
-
clusterBumpEpoch
Description copied from interface:ClusterCommandsAdvance the cluster config epoch.- Specified by:
clusterBumpEpochin interfaceClusterCommands- Returns:
- BUMPED if the epoch was incremented, or STILL if the node already has the greatest config epoch in the cluster.
-
clusterReplicate
- Specified by:
clusterReplicatein interfaceClusterCommands
-
clusterSlaves
Deprecated.Description copied from interface:ClusterCommandsCLUSTER SLAVEScommand is deprecated since Redis 5.- Specified by:
clusterSlavesin interfaceClusterCommands
-
clusterReplicas
- Specified by:
clusterReplicasin interfaceClusterCommands
-
clusterFailover
- Specified by:
clusterFailoverin interfaceClusterCommands
-
clusterFailover
- Specified by:
clusterFailoverin interfaceClusterCommands
-
clusterSlots
- Specified by:
clusterSlotsin interfaceClusterCommands
-
clusterMyId
- Specified by:
clusterMyIdin interfaceClusterCommands
-
clusterMyShardId
- Specified by:
clusterMyShardIdin interfaceClusterCommands
-
clusterLinks
Description copied from interface:ClusterCommandsreturn the information of all such peer links as an array, where each array element is a map that contains attributes and their values for an individual link.- Specified by:
clusterLinksin interfaceClusterCommands- Returns:
- the information of all such peer links as an array
- See Also:
-
clusterAddSlotsRange
Description copied from interface:ClusterCommandsTakes a list of slot ranges (specified by start and end slots) to assign to the node- Specified by:
clusterAddSlotsRangein interfaceClusterCommands- Parameters:
ranges- slots range- Returns:
- OK if the command was successful. Otherwise an error is returned.
-
clusterDelSlotsRange
Description copied from interface:ClusterCommandsTakes a list of slot ranges (specified by start and end slots) to remove to the node.- Specified by:
clusterDelSlotsRangein interfaceClusterCommands- Parameters:
ranges- slots range- Returns:
- OK if the command was successful. Otherwise an error is returned.
-
asking
- Specified by:
askingin interfaceClusterCommands
-
pfadd
- Specified by:
pfaddin interfaceHyperLogLogCommands
-
pfcount
- Specified by:
pfcountin interfaceHyperLogLogCommands
-
pfcount
- Specified by:
pfcountin interfaceHyperLogLogCommands
-
pfmerge
- Specified by:
pfmergein interfaceHyperLogLogCommands
-
fcall
Description copied from interface:FunctionCommandsInvoke a function.- Specified by:
fcallin interfaceFunctionCommands- Parameters:
name-keys-args-
-
fcallReadonly
Description copied from interface:FunctionCommandsThis is a read-only variant of theFCALLcommand that cannot execute commands that modify data.- Specified by:
fcallReadonlyin interfaceFunctionCommands
-
functionDelete
Description copied from interface:FunctionCommandsThis command deletes the library called library-name and all functions in it. If the library doesn't exist, the server returns an error.- Specified by:
functionDeletein interfaceFunctionCommands- Parameters:
libraryName-- Returns:
- OK
-
functionLoad
Description copied from interface:FunctionCommandsLoad a library to Redis.The library payload must start with Shebang statement that provides a metadata about the library (like the engine to use and the library name). Shebang format:
#!<engine name> name=<library name>. Currently engine name must be lua.- Specified by:
functionLoadin interfaceFunctionCommands- Parameters:
functionCode- the source code.- Returns:
- The library name that was loaded
-
functionLoadReplace
Description copied from interface:FunctionCommandsLoad a library to Redis. Will replace the current library if it already exists.- Specified by:
functionLoadReplacein interfaceFunctionCommands- Parameters:
functionCode- the source code- Returns:
- The library name that was loaded
-
functionStats
Description copied from interface:FunctionCommandsReturn information about the function that's currently running and information about the available execution engines.- Specified by:
functionStatsin interfaceFunctionCommands- Returns:
FunctionStats
-
functionFlush
Description copied from interface:FunctionCommandsDeletes all the libraries, unless called with the optional mode argument, the 'lazyfree-lazy-user-flush' configuration directive sets the effective behavior.- Specified by:
functionFlushin interfaceFunctionBinaryCommands- Specified by:
functionFlushin interfaceFunctionCommands- Returns:
- OK
-
functionFlush
Description copied from interface:FunctionCommandsDeletes all the libraries, unless called with the optional mode argument, the 'lazyfree-lazy-user-flush' configuration directive sets the effective behavior.- Specified by:
functionFlushin interfaceFunctionBinaryCommands- Specified by:
functionFlushin interfaceFunctionCommands- Parameters:
mode- ASYNC: Asynchronously flush the libraries, SYNC: Synchronously flush the libraries.- Returns:
- OK
-
functionKill
Description copied from interface:FunctionCommandsKill a function that is currently executing. The command can be used only on functions that did not modify the dataset during their execution.- Specified by:
functionKillin interfaceFunctionBinaryCommands- Specified by:
functionKillin interfaceFunctionCommands- Returns:
- OK
-
functionList
Description copied from interface:FunctionCommandsReturn information about the functions and libraries.- Specified by:
functionListin interfaceFunctionCommands- Returns:
LibraryInfo
-
functionList
Description copied from interface:FunctionCommandsReturn information about the functions and libraries.- Specified by:
functionListin interfaceFunctionCommands- Parameters:
libraryNamePattern- a pattern for matching library names- Returns:
LibraryInfo
-
functionListWithCode
Description copied from interface:FunctionCommandsSimilar toFUNCTION LISTbut include the libraries source implementation in the reply.- Specified by:
functionListWithCodein interfaceFunctionCommands- Returns:
LibraryInfo- See Also:
-
functionListWithCode
Description copied from interface:FunctionCommandsSimilar toFUNCTION LISTbut include the libraries source implementation in the reply.- Specified by:
functionListWithCodein interfaceFunctionCommands- Parameters:
libraryNamePattern- a pattern for matching library names- Returns:
LibraryInfo- See Also:
-
geoadd
Description copied from interface:GeoCommandsAdds the specified geospatial item (longitude, latitude, member) to the specified key.Time complexity: O(log(N)) where N is the number of elements in the sorted set.
- Specified by:
geoaddin interfaceGeoCommands- Parameters:
key-longitude-latitude-member-- Returns:
- The number of elements added
-
geoadd
Description copied from interface:GeoCommandsAdds the specified geospatial items (in memberCoordinateMap) to the specified key.Time complexity: O(log(N)) for each item added, where N is the number of elements in the sorted set.
- Specified by:
geoaddin interfaceGeoCommands- Parameters:
key-memberCoordinateMap- Members names with their geo coordinates- Returns:
- The number of elements added
-
geoadd
Description copied from interface:GeoCommandsAdds the specified geospatial items (in memberCoordinateMap) to the specified key. Can be used with the following options: XX- Only update elements that already exist. Never add elements. NX- Don't update already existing elements. Always add new elements. CH- Modify the return value from the number of new elements added, to the total number of elements changedTime complexity: O(log(N)) for each item added
- Specified by:
geoaddin interfaceGeoCommands- Parameters:
key-params- Additional optionsmemberCoordinateMap- Members names with their geo coordinates- Returns:
- The number of elements added
-
geodist
Description copied from interface:GeoCommandsReturn the distance between two members in the geospatial index represented by the sorted set.Time complexity: O(log(N))
- Specified by:
geodistin interfaceGeoCommands- Parameters:
key-member1-member2-- Returns:
- The distance as a double
-
geodist
Description copied from interface:GeoCommandsReturn the distance between two members in the geospatial index represented by the sorted set.Time complexity: O(log(N))
- Specified by:
geodistin interfaceGeoCommands- Parameters:
key-member1-member2-unit- can be M, KM, MI or FT can M, KM, MI or FT- Returns:
- The distance as a double
-
geohash
Description copied from interface:GeoCommandsReturn valid Geohash strings representing the position of the given members.Time complexity: O(log(N)) for each member requested
- Specified by:
geohashin interfaceGeoCommands- Parameters:
key-members-- Returns:
- A list of Geohash strings corresponding to each member name passed as argument to the command.
-
geopos
Description copied from interface:GeoCommandsReturn the positions (longitude,latitude) of all the specified members.Time complexity: O(N) where N is the number of members requested.
- Specified by:
geoposin interfaceGeoCommands- Parameters:
key-members-- Returns:
- A list of GeoCoordinate representing longitude and latitude (x,y) of each member name passed as argument to the command.
-
georadius
public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude, double radius, GeoUnit unit) Description copied from interface:GeoCommandsReturn the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified with the center location and the radius.Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
- Specified by:
georadiusin interfaceGeoCommands- Parameters:
key-longitude- of the center pointlatitude- of the center pointradius- of the areaunit- can be M, KM, MI or FT- Returns:
- List of GeoRadiusResponse
-
georadiusReadonly
public List<GeoRadiusResponse> georadiusReadonly(String key, double longitude, double latitude, double radius, GeoUnit unit) Description copied from interface:GeoCommandsReadonly version ofGEORADIUS,Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
- Specified by:
georadiusReadonlyin interfaceGeoCommands- Parameters:
key-longitude- of the center pointlatitude- of the center pointradius- of the areaunit- can be M, KM, MI or FT- Returns:
- List of GeoRadiusResponse
- See Also:
-
georadius
public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param) Description copied from interface:GeoCommandsReturn the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified with the center location and the radius. Additional information can be reached usingGeoRadiusParam: WITHDIST: Also return the distance of the returned items from the specified center. The distance is returned in the same unit as the unit specified as the radius argument of the command. WITHCOORD: Also return the longitude,latitude coordinates of the matching items. WITHHASH: Also return the raw geohash-encoded sorted set score of the item, in the form of a 52 bit unsigned integer. This is only useful for low level hacks or debugging and is otherwise of little interest for the general user.Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
- Specified by:
georadiusin interfaceGeoCommands- Parameters:
key-longitude- of the center pointlatitude- of the center pointradius- of the areaunit- can be M, KM, MI or FTparam-GeoRadiusParam- Returns:
- List of GeoRadiusResponse
-
georadiusStore
public long georadiusStore(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam) Description copied from interface:GeoCommandsThis command is exactly likeGEORADIUSbut storing the results at the destination key (provided withstoreParam).Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
- Specified by:
georadiusStorein interfaceGeoCommands- Parameters:
key-longitude- of the center pointlatitude- of the center pointradius- of the areaunit- can be M, KM, MI or FTparam-GeoRadiusParamstoreParam-GeoRadiusStoreParam- Returns:
- The number of results being stored
-
georadiusReadonly
public List<GeoRadiusResponse> georadiusReadonly(String key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param) Description copied from interface:GeoCommandsReadonly version ofGEORADIUS,Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
- Specified by:
georadiusReadonlyin interfaceGeoCommands- Parameters:
key-longitude- of the center pointlatitude- of the center pointradius- of the areaunit- can be M, KM, MI or FTparam-GeoRadiusParam- Returns:
- List of GeoRadiusResponse
- See Also:
-
georadiusByMember
public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius, GeoUnit unit) Description copied from interface:GeoCommandsThis command is exactly likeGEORADIUSwith the sole difference that instead of taking, as the center of the area to query, a longitude and latitude value, it takes the name of a member already existing inside the geospatial index represented by the sorted set.Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
- Specified by:
georadiusByMemberin interfaceGeoCommands- Parameters:
key-member- represents the center of the arearadius- of the areaunit- can be M, KM, MI or FT- Returns:
- List of GeoRadiusResponse
-
georadiusByMemberReadonly
public List<GeoRadiusResponse> georadiusByMemberReadonly(String key, String member, double radius, GeoUnit unit) Description copied from interface:GeoCommandsReadonly version ofGEORADIUSBYMEMBERTime complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
- Specified by:
georadiusByMemberReadonlyin interfaceGeoCommands- Parameters:
key-member- represents the center of the arearadius- of the areaunit- can be M, KM, MI or FT- Returns:
- List of GeoRadiusResponse
-
georadiusByMember
public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param) Description copied from interface:GeoCommandsThis command is exactly likeGEORADIUSwith the sole difference that instead of taking, as the center of the area to query, a longitude and latitude value, it takes the name of a member already existing inside the geospatial index represented by the sorted set.Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
- Specified by:
georadiusByMemberin interfaceGeoCommands- Parameters:
key-member- represents the center of the arearadius- of the areaunit- can be M, KM, MI or FTparam-GeoRadiusParam- Returns:
- List of GeoRadiusResponse
-
georadiusByMemberStore
public long georadiusByMemberStore(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam) Description copied from interface:GeoCommandsThis command is exactly likeGEORADIUSBYMEMBERbut storing the results at the destination key (provided withstoreParam).Time complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
- Specified by:
georadiusByMemberStorein interfaceGeoCommands- Parameters:
key-member- represents the center of the arearadius- of the areaunit- can be M, KM, MI or FTparam-GeoRadiusParamstoreParam-GeoRadiusStoreParam- Returns:
- The number of results being stored
-
georadiusByMemberReadonly
public List<GeoRadiusResponse> georadiusByMemberReadonly(String key, String member, double radius, GeoUnit unit, GeoRadiusParam param) Description copied from interface:GeoCommandsReadonly version ofGEORADIUSBYMEMBERTime complexity: O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
- Specified by:
georadiusByMemberReadonlyin interfaceGeoCommands- Parameters:
key-member- represents the center of the arearadius- of the areaunit- can be M, KM, MI or FTparam-GeoRadiusParam- Returns:
- List of GeoRadiusResponse
-
geosearch
Description copied from interface:GeoCommandsReturn the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified by a given shape.This command can be used in place of the
GEORADIUSBYMEMBERcommand.Time complexity: O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
- Specified by:
geosearchin interfaceGeoCommands- Parameters:
key-member- represents the center of the arearadius- of the areaunit- can be M, KM, MI or FT- Returns:
- List of GeoRadiusResponse
-
geosearch
public List<GeoRadiusResponse> geosearch(String key, GeoCoordinate coord, double radius, GeoUnit unit) Description copied from interface:GeoCommandsReturn the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified by a given shape.This command can be used in place of the
GEORADIUScommand.Time complexity: O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
- Specified by:
geosearchin interfaceGeoCommands- Parameters:
key-coord- represents the center of the arearadius- of the areaunit- can be M, KM, MI or FT- Returns:
- List of GeoRadiusResponse
-
geosearch
public List<GeoRadiusResponse> geosearch(String key, String member, double width, double height, GeoUnit unit) Description copied from interface:GeoCommandsReturn the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified by a given shape. This command extends the GEORADIUS command, so in addition to searching within circular areas, it supports searching within rectangular areas.The axis-aligned rectangle, determined by height and width, when the center point is determined by the position of the given member.
Time complexity: O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
- Specified by:
geosearchin interfaceGeoCommands- Parameters:
key-member- represents the center of the areawidth- of the rectangular areaheight- of the rectangular areaunit- can be M, KM, MI or FT- Returns:
- List of GeoRadiusResponse
-
geosearch
public List<GeoRadiusResponse> geosearch(String key, GeoCoordinate coord, double width, double height, GeoUnit unit) Description copied from interface:GeoCommandsReturn the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified by a given shape. This command extends the GEORADIUS command, so in addition to searching within circular areas, it supports searching within rectangular areas.The axis-aligned rectangle, determined by height and width, when the center point is determined by the given coordinate.
Time complexity: O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
- Specified by:
geosearchin interfaceGeoCommands- Parameters:
key-coord- represents the center pointwidth- of the rectangular areaheight- of the rectangular areaunit- can be M, KM, MI or FT- Returns:
- List of GeoRadiusResponse
-
geosearch
Description copied from interface:GeoCommandsReturn the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified by a given shape. This command extends the GEORADIUS command, so in addition to searching within circular areas, it supports searching within rectangular areas.Time complexity: O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
- Specified by:
geosearchin interfaceGeoCommands- Parameters:
key-params-GeoSearchParam- Returns:
- List of GeoRadiusResponse
-
geosearchStore
Description copied from interface:GeoCommandsThis command is exactly likeGEOSEARCHbut storing the results at dest.Time complexity: O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
- Specified by:
geosearchStorein interfaceGeoCommands- Parameters:
dest-src- the sorted set (key)member- represents the center of the arearadius- of the circular areaunit- can be M, KM, MI or FT- Returns:
- The number of results being stored
-
geosearchStore
public long geosearchStore(String dest, String src, GeoCoordinate coord, double radius, GeoUnit unit) Description copied from interface:GeoCommandsThis command is exactly likeGEOSEARCHbut storing the results at dest.Time complexity: O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
- Specified by:
geosearchStorein interfaceGeoCommands- Parameters:
dest-src-coord- represents the center pointradius- of the circular areaunit- can be M, KM, MI or FT- Returns:
- The number of results being stored
-
geosearchStore
public long geosearchStore(String dest, String src, String member, double width, double height, GeoUnit unit) Description copied from interface:GeoCommandsThis command is exactly likeGEOSEARCHbut storing the results at dest.Time complexity: O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
- Specified by:
geosearchStorein interfaceGeoCommands- Parameters:
dest-src-member- represents the center of the areawidth- of the rectangular areaheight- of the rectangular areaunit- can be M, KM, MI or FT- Returns:
- The number of results being stored
-
geosearchStore
public long geosearchStore(String dest, String src, GeoCoordinate coord, double width, double height, GeoUnit unit) Description copied from interface:GeoCommandsThis command is exactly likeGEOSEARCHbut storing the results at dest.Time complexity: O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
- Specified by:
geosearchStorein interfaceGeoCommands- Parameters:
dest-src-coord- represents the center pointwidth- of the rectangular areaheight- of the rectangular areaunit- can be M, KM, MI or FT- Returns:
- The number of results being stored
-
geosearchStore
Description copied from interface:GeoCommandsThis command is exactly likeGEOSEARCHbut storing the results at dest.Time complexity: O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
- Specified by:
geosearchStorein interfaceGeoCommands- Parameters:
dest-src-params-GeoSearchParam- Returns:
- The number of results being stored
-
geosearchStoreStoreDist
Description copied from interface:GeoCommandsThis command is exactly likeGEOSEARCHSTOREbut storing the results with their destinations from the center point.Time complexity: O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
- Specified by:
geosearchStoreStoreDistin interfaceGeoCommands- Parameters:
dest-src-params-GeoSearchParam- Returns:
- The number of results being stored
-
moduleLoad
Description copied from interface:ModuleCommandsLoad and initialize the Redis module from the dynamic library specified by the path argument.- Specified by:
moduleLoadin interfaceModuleCommands- Parameters:
path- should be the absolute path of the library, including the full filename- Returns:
- OK
-
moduleLoad
Description copied from interface:ModuleCommandsLoad and initialize the Redis module from the dynamic library specified by the path argument.- Specified by:
moduleLoadin interfaceModuleCommands- Parameters:
path- should be the absolute path of the library, including the full filenameargs- additional arguments are passed unmodified to the module- Returns:
- OK
-
moduleLoadEx
Description copied from interface:ModuleCommandsLoads a module from a dynamic library at runtime with configuration directives.This is an extended version of the MODULE LOAD command.
It loads and initializes the Redis module from the dynamic library specified by the path argument. The path should be the absolute path of the library, including the full filename.
You can use the optional CONFIG argument to provide the module with configuration directives. Any additional arguments that follow the ARGS keyword are passed unmodified to the module.
- Specified by:
moduleLoadExin interfaceModuleCommands- Parameters:
path- should be the absolute path of the library, including the full filenameparams- as in description- Returns:
- OK
-
moduleUnload
Description copied from interface:ModuleCommandsUnload the module specified by name. Note that the module's name is reported by theMODULE LISTcommand, and may differ from the dynamic library's filename.- Specified by:
moduleUnloadin interfaceModuleCommands- Parameters:
name-- Returns:
- OK
-
moduleList
Description copied from interface:ModuleCommandsReturn information about the modules loaded to the server.- Specified by:
moduleListin interfaceGenericControlCommands- Specified by:
moduleListin interfaceModuleCommands- Returns:
- list of
Module
-
bitfield
Description copied from interface:BitCommandsBitfield Command The command treats a Redis string as an array of bits, and is capable of addressing specific integer fields of varying bit widths and arbitrary non (necessary) aligned offset.- Specified by:
bitfieldin interfaceBitCommands- Parameters:
key-arguments- may be used with optional arguments- Returns:
- A List of results
-
bitfieldReadonly
Description copied from interface:BitCommandsThe readonly version ofBITFIELD- Specified by:
bitfieldReadonlyin interfaceBitCommands
-
hstrlen
- Specified by:
hstrlenin interfaceHashCommands
-
memoryDoctor
Description copied from interface:ControlCommandsReports about different memory-related issues that the Redis server experiences, and advises about possible remedies.- Specified by:
memoryDoctorin interfaceControlCommands
-
memoryUsage
Description copied from interface:KeyCommandsMemory Usage Command Report the number of bytes that a key and its value require to be stored in RAM.Time complexity: O(1)
- Specified by:
memoryUsagein interfaceControlCommands- Specified by:
memoryUsagein interfaceKeyCommands- Parameters:
key-- Returns:
- The memory usage in bytes
-
memoryUsage
Description copied from interface:KeyCommandsMemory Usage Command Report the number of bytes that a key and its value require to be stored in RAM.Time complexity: O(1)
- Specified by:
memoryUsagein interfaceControlCommands- Specified by:
memoryUsagein interfaceKeyCommands- Parameters:
key-samples- the number of sampled nested values. By default, this option is set to 5. To sample the all the nested values, use 0.- Returns:
- The memory usage in bytes
-
memoryPurge
Description copied from interface:ControlCommandsAttempts to purge dirty pages so these can be reclaimed by the allocator.- Specified by:
memoryPurgein interfaceControlCommands- Returns:
- OK
-
memoryStats
Description copied from interface:ControlCommandsReturns an Array reply about the memory usage of the server.- Specified by:
memoryStatsin interfaceControlCommands- Returns:
- nested list of memory usage metrics and their values
-
lolwut
- Specified by:
lolwutin interfaceServerCommands
-
lolwut
- Specified by:
lolwutin interfaceServerCommands
-
latencyDoctor
Description copied from interface:ServerCommandsThe LATENCY DOCTOR command reports about different latency-related issues and advises about possible remedies.This command is the most powerful analysis tool in the latency monitoring framework, and is able to provide additional statistical data like the average period between latency spikes, the median deviation, and a human-readable analysis of the event. For certain events, like fork, additional information is provided, like the rate at which the system forks processes.
This is the output you should post in the Redis mailing list if you are looking for help about Latency related issues.
- Specified by:
latencyDoctorin interfaceServerCommands- Returns:
- the report
-
xadd
Description copied from interface:StreamCommandsXADD key ID field string [field string ...]- Specified by:
xaddin interfaceStreamCommands- Returns:
- the ID of the added entry
-
xadd
- Specified by:
xaddin interfaceStreamCommands
-
xlen
Description copied from interface:StreamCommandsXLEN key- Specified by:
xlenin interfaceStreamCommands- Returns:
- length of stream
-
xrange
Description copied from interface:StreamCommandsXRANGE key start end- Specified by:
xrangein interfaceStreamCommands- Parameters:
key-start- minimumStreamEntryIDfor the retrieved range, passingnullwill indicate minimum ID possible in the streamend- maximumStreamEntryIDfor the retrieved range, passingnullwill indicate maximum ID possible in the stream- Returns:
- The entries with IDs matching the specified range.
-
xrange
Description copied from interface:StreamCommandsXRANGE key start end COUNT count- Specified by:
xrangein interfaceStreamCommands- Parameters:
key-start- minimumStreamEntryIDfor the retrieved range, passingnullwill indicate minimum ID possible in the streamend- maximumStreamEntryIDfor the retrieved range, passingnullwill indicate maximum ID possible in the streamcount- maximum number of entries returned- Returns:
- The entries with IDs matching the specified range.
-
xrevrange
Description copied from interface:StreamCommandsXREVRANGE key end start- Specified by:
xrevrangein interfaceStreamCommands- Parameters:
key-end- maximumStreamEntryIDfor the retrieved range, passingnullwill indicate maximum ID possible in the streamstart- minimumStreamEntryIDfor the retrieved range, passingnullwill indicate minimum ID possible in the stream- Returns:
- the entries with IDs matching the specified range, from the higher ID to the lower ID matching.
-
xrevrange
Description copied from interface:StreamCommandsXREVRANGE key end start COUNT count- Specified by:
xrevrangein interfaceStreamCommands- Parameters:
key-end- maximumStreamEntryIDfor the retrieved range, passingnullwill indicate maximum ID possible in the streamstart- minimumStreamEntryIDfor the retrieved range, passingnullwill indicate minimum ID possible in the streamcount- The entries with IDs matching the specified range.- Returns:
- the entries with IDs matching the specified range, from the higher ID to the lower ID matching.
-
xrange
- Specified by:
xrangein interfaceStreamCommands
-
xrange
- Specified by:
xrangein interfaceStreamCommands
-
xrevrange
- Specified by:
xrevrangein interfaceStreamCommands
-
xrevrange
- Specified by:
xrevrangein interfaceStreamCommands
-
xread
public List<Map.Entry<String,List<StreamEntry>>> xread(XReadParams xReadParams, Map<String, StreamEntryID> streams) Description copied from interface:StreamCommandsXREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]- Specified by:
xreadin interfaceStreamCommands
-
xack
Description copied from interface:StreamCommandsXACK key group ID [ID ...]- Specified by:
xackin interfaceStreamCommands
-
xgroupCreate
Description copied from interface:StreamCommandsXGROUP CREATE key groupName <id or $>- Specified by:
xgroupCreatein interfaceStreamCommands
-
xgroupSetID
Description copied from interface:StreamCommandsXGROUP SETID key groupName <id or $>- Specified by:
xgroupSetIDin interfaceStreamCommands
-
xgroupDestroy
Description copied from interface:StreamCommandsXGROUP DESTROY key groupName- Specified by:
xgroupDestroyin interfaceStreamCommands
-
xgroupCreateConsumer
Description copied from interface:StreamCommandsXGROUP CREATECONSUMER key groupName consumerName- Specified by:
xgroupCreateConsumerin interfaceStreamCommands
-
xgroupDelConsumer
Description copied from interface:StreamCommandsXGROUP DELCONSUMER key groupName consumerName- Specified by:
xgroupDelConsumerin interfaceStreamCommands
-
xdel
Description copied from interface:StreamCommandsXDEL key ID [ID ...]- Specified by:
xdelin interfaceStreamCommands
-
xtrim
Description copied from interface:StreamCommandsXTRIM key MAXLEN [~] count- Specified by:
xtrimin interfaceStreamCommands
-
xtrim
Description copied from interface:StreamCommandsXTRIM key MAXLEN|MINID [=|~] threshold [LIMIT count]- Specified by:
xtrimin interfaceStreamCommands
-
xreadGroup
public List<Map.Entry<String,List<StreamEntry>>> xreadGroup(String groupName, String consumer, XReadGroupParams xReadGroupParams, Map<String, StreamEntryID> streams) Description copied from interface:StreamCommandsXREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]- Specified by:
xreadGroupin interfaceStreamCommands
-
xpending
Description copied from interface:StreamCommandsXPENDING key group- Specified by:
xpendingin interfaceStreamCommands
-
xpending
@Deprecated public List<StreamPendingEntry> xpending(String key, String groupName, StreamEntryID start, StreamEntryID end, int count, String consumerName) Deprecated.Description copied from interface:StreamCommandsXPENDING key group [start end count] [consumer]- Specified by:
xpendingin interfaceStreamCommands
-
xpending
Description copied from interface:StreamCommandsXPENDING key group [[IDLE min-idle-time] start end count [consumer]]- Specified by:
xpendingin interfaceStreamCommands
-
xclaim
public List<StreamEntry> xclaim(String key, String group, String consumerName, long minIdleTime, XClaimParams params, StreamEntryID... ids) Description copied from interface:StreamCommandsXCLAIM key group consumer min-idle-time <ID-1> ... <ID-N> [IDLE <milliseconds>] [TIME <mstime>] [RETRYCOUNT <count>] [FORCE]- Specified by:
xclaimin interfaceStreamCommands
-
xclaimJustId
public List<StreamEntryID> xclaimJustId(String key, String group, String consumerName, long minIdleTime, XClaimParams params, StreamEntryID... ids) Description copied from interface:StreamCommandsXCLAIM key group consumer min-idle-time <ID-1> ... <ID-N> [IDLE <milliseconds>] [TIME <mstime>] [RETRYCOUNT <count>] [FORCE] JUSTID- Specified by:
xclaimJustIdin interfaceStreamCommands
-
xautoclaim
public Map.Entry<StreamEntryID,List<StreamEntry>> xautoclaim(String key, String group, String consumerName, long minIdleTime, StreamEntryID start, XAutoClaimParams params) Description copied from interface:StreamCommandsXAUTOCLAIM key group consumer min-idle-time start [COUNT count]- Specified by:
xautoclaimin interfaceStreamCommands- Parameters:
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, passingnullwill indicate '-'params-XAutoClaimParams
-
xautoclaimJustId
public Map.Entry<StreamEntryID,List<StreamEntryID>> xautoclaimJustId(String key, String group, String consumerName, long minIdleTime, StreamEntryID start, XAutoClaimParams params) Description copied from interface:StreamCommandsXAUTOCLAIM key group consumer min-idle-time start [COUNT count] JUSTID- Specified by:
xautoclaimJustIdin interfaceStreamCommands- Parameters:
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, passingnullwill indicate '-'params-XAutoClaimParams
-
xinfoStream
Description copied from interface:StreamCommandsIntrospection command used in order to retrieve different information about the stream- Specified by:
xinfoStreamin interfaceStreamCommands- Parameters:
key- Stream name- Returns:
StreamInfothat contains information about the stream
-
xinfoStreamFull
Description copied from interface:StreamCommandsIntrospection command used in order to retrieve all information about the stream- Specified by:
xinfoStreamFullin interfaceStreamCommands- Parameters:
key- Stream name- Returns:
StreamFullInfothat contains information about the stream
-
xinfoStreamFull
Description copied from interface:StreamCommandsIntrospection command used in order to retrieve all information about the stream- Specified by:
xinfoStreamFullin interfaceStreamCommands- Parameters:
key- Stream namecount- stream info count- Returns:
StreamFullInfothat contains information about the stream
-
xinfoGroup
Deprecated.- Specified by:
xinfoGroupin interfaceStreamCommands
-
xinfoGroups
Description copied from interface:StreamCommandsIntrospection command used in order to retrieve different information about groups in the stream- Specified by:
xinfoGroupsin interfaceStreamCommands- Parameters:
key- Stream name- Returns:
- List of
StreamGroupInfocontaining information about groups
-
xinfoConsumers
Description copied from interface:StreamCommandsIntrospection command used in order to retrieve different information about consumers in the group- Specified by:
xinfoConsumersin interfaceStreamCommands- Parameters:
key- Stream namegroup- Group name- Returns:
- List of
StreamConsumersInfocontaining information about consumers that belong to the the group
-
fcall
Description copied from interface:FunctionBinaryCommandsInvoke a function.- Specified by:
fcallin interfaceFunctionBinaryCommands- Parameters:
name-keys-args-- Returns:
-
fcallReadonly
- Specified by:
fcallReadonlyin interfaceFunctionBinaryCommands
-
functionDelete
Description copied from interface:FunctionBinaryCommandsThis command deletes the library called library-name and all functions in it. If the library doesn't exist, the server returns an error.- Specified by:
functionDeletein interfaceFunctionBinaryCommands- Parameters:
libraryName-- Returns:
- OK
-
functionDump
public byte[] functionDump()Description copied from interface:FunctionCommandsReturn the serialized payload of loaded libraries. You can restore the serialized payload later with theFUNCTION RESTOREcommand.- Specified by:
functionDumpin interfaceFunctionBinaryCommands- Specified by:
functionDumpin interfaceFunctionCommands- Returns:
- the serialized payload
-
functionListBinary
Description copied from interface:FunctionBinaryCommandsReturn information about the functions and libraries.- Specified by:
functionListBinaryin interfaceFunctionBinaryCommands- Returns:
LibraryInfo
-
functionList
Description copied from interface:FunctionBinaryCommandsReturn information about the functions and libraries.- Specified by:
functionListin interfaceFunctionBinaryCommands- Parameters:
libraryNamePattern- a pattern for matching library names- Returns:
LibraryInfo
-
functionListWithCodeBinary
Description copied from interface:FunctionBinaryCommandsSimilar toFUNCTION LISTbut include the libraries source implementation in the reply.- Specified by:
functionListWithCodeBinaryin interfaceFunctionBinaryCommands- Returns:
LibraryInfo- See Also:
-
functionListWithCode
Description copied from interface:FunctionBinaryCommandsSimilar toFUNCTION LISTbut include the libraries source implementation in the reply.- Specified by:
functionListWithCodein interfaceFunctionBinaryCommands- Parameters:
libraryNamePattern- a pattern for matching library names- Returns:
LibraryInfo- See Also:
-
functionLoad
Description copied from interface:FunctionBinaryCommandsLoad a library to Redis.The library payload must start with Shebang statement that provides a metadata about the library (like the engine to use and the library name). Shebang format:
#!<engine name> name=<library name>. Currently engine name must be lua.- Specified by:
functionLoadin interfaceFunctionBinaryCommands- Parameters:
functionCode- the source code.- Returns:
- The library name that was loaded
-
functionLoadReplace
Description copied from interface:FunctionBinaryCommandsLoad a library to Redis. Will replace the current library if it already exists.- Specified by:
functionLoadReplacein interfaceFunctionBinaryCommands- Parameters:
functionCode- the source code- Returns:
- The library name that was loaded
-
functionRestore
Description copied from interface:FunctionCommandsRestore libraries from the serialized payload. Default policy is APPEND.- Specified by:
functionRestorein interfaceFunctionBinaryCommands- Specified by:
functionRestorein interfaceFunctionCommands- Parameters:
serializedValue- the serialized payload- Returns:
- OK
-
functionRestore
Description copied from interface:FunctionCommandsRestore libraries from the serialized payload.- Specified by:
functionRestorein interfaceFunctionBinaryCommands- Specified by:
functionRestorein interfaceFunctionCommands- Parameters:
serializedValue- the serialized payloadpolicy- can beFLUSH, APPEND or REPLACE- Returns:
- OK
-
functionStatsBinary
Description copied from interface:FunctionBinaryCommandsReturn information about the function that's currently running and information about the available execution engines.- Specified by:
functionStatsBinaryin interfaceFunctionBinaryCommands- Returns:
FunctionStats
-
sendCommand
-
sendBlockingCommand
-
joinParameters
private static byte[][] joinParameters(int... params) -
joinParameters
private static byte[][] joinParameters(byte[] first, byte[][] rest) -
joinParameters
private static byte[][] joinParameters(byte[] first, byte[] second, byte[][] rest) -
joinParameters
-
joinParameters
-