Class Jedis

java.lang.Object
redis.clients.jedis.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 Details

    • connection

      protected final Connection connection
    • commandObjects

      private final CommandObjects commandObjects
    • db

      private int db
    • transaction

      private Transaction transaction
    • isInMulti

      private boolean isInMulti
    • isInWatch

      private boolean isInWatch
    • pipeline

      private Pipeline pipeline
    • DUMMY_ARRAY

      protected static final byte[][] DUMMY_ARRAY
    • dataSource

      private Pool<Jedis> dataSource
  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getClient

      public Connection getClient()
    • getConnection

      public Connection 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

      protected void setDataSource(Pool<Jedis> jedisPool)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • multi

      public Transaction multi()
    • pipelined

      public Pipeline pipelined()
    • checkIsInMultiOrPipeline

      protected void checkIsInMultiOrPipeline()
    • getDB

      public int getDB()
    • ping

      public String ping()
      Description copied from interface: ServerCommands
      This command is often used to test if a connection is still alive, or to measure latency.
      Specified by:
      ping in interface ServerCommands
      Returns:
      PONG
    • ping

      public byte[] ping(byte[] message)
      Works same as ping() but returns argument message instead of PONG.
      Parameters:
      message -
      Returns:
      message
    • select

      public String select(int index)
      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:
      select in interface DatabaseCommands
      Parameters:
      index -
      Returns:
      OK
    • swapDB

      public String swapDB(int index1, int index2)
      Description copied from interface: DatabaseCommands
      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.
      Specified by:
      swapDB in interface DatabaseCommands
      Parameters:
      index1 -
      index2 -
      Returns:
      OK
    • flushDB

      public String flushDB()
      Delete all the keys of the currently selected DB. This command never fails.
      Specified by:
      flushDB in interface DatabaseCommands
      Specified by:
      flushDB in interface ServerCommands
      Returns:
      OK
    • flushDB

      public String flushDB(FlushMode flushMode)
      Delete all the keys of the currently selected DB. This command never fails.
      Specified by:
      flushDB in interface DatabaseCommands
      Specified by:
      flushDB in interface ServerCommands
      Parameters:
      flushMode -
      Returns:
      OK
    • flushAll

      public String flushAll()
      Delete all the keys of all the existing databases, not just the currently selected one. This command never fails.
      Specified by:
      flushAll in interface ServerCommands
      Returns:
      OK
    • flushAll

      public String flushAll(FlushMode flushMode)
      Delete all the keys of all the existing databases, not just the currently selected one. This command never fails.
      Specified by:
      flushAll in interface ServerCommands
      Parameters:
      flushMode -
      Returns:
      OK
    • quit

      @Deprecated public String quit()
      Deprecated.
      The QUIT command is deprecated, see #11420. disconnect() can be used instead.
      Ask the server to silently close the connection.
      Specified by:
      quit in interface ServerCommands
      Returns:
      OK
    • copy

      public boolean copy(byte[] srcKey, byte[] dstKey, int db, boolean replace)
      COPY source destination [DB destination-db] [REPLACE]
      Specified by:
      copy in interface DatabaseCommands
      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:
      copy in interface KeyBinaryCommands
      Parameters:
      srcKey - the source key.
      dstKey - the destination key.
      replace -
    • set

      public String set(byte[] key, byte[] value)
      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:
      set in interface StringBinaryCommands
      Parameters:
      key -
      value -
      Returns:
      OK
    • set

      public String set(byte[] key, byte[] value, SetParams params)
      Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1 GB).
      Specified by:
      set in interface StringBinaryCommands
      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 OK if SET was executed correctly, or null if the SET operation 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:
      get in interface StringBinaryCommands
      Parameters:
      key -
      Returns:
      Bulk reply
    • setGet

      public byte[] setGet(byte[] key, byte[] value, SetParams params)
      Description copied from interface: StringBinaryCommands
      WARNING: SetParams.get() MUST NOT be used with this method.
      Specified by:
      setGet in interface StringBinaryCommands
    • 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:
      getDel in interface StringBinaryCommands
      Parameters:
      key -
      Returns:
      The value of key
    • getEx

      public byte[] getEx(byte[] key, GetExParams params)
      Specified by:
      getEx in interface StringBinaryCommands
    • 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:
      exists in interface KeyBinaryCommands
      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:
      exists in interface KeyBinaryCommands
      Parameters:
      key -
      Returns:
      true if the key exists, otherwise false
    • 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:
      del in interface KeyBinaryCommands
      Parameters:
      keys -
      Returns:
      The number of keys that were removed
    • del

      public long del(byte[] key)
      Specified by:
      del in interface KeyBinaryCommands
    • 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:
      unlink in interface KeyBinaryCommands
      Parameters:
      keys -
      Returns:
      The number of keys that were unlinked
    • unlink

      public long unlink(byte[] key)
      Specified by:
      unlink in interface KeyBinaryCommands
    • type

      public String type(byte[] key)
      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:
      type in interface KeyBinaryCommands
      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

      public Set<byte[]> keys(byte[] pattern)
      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:
      keys in interface KeyBinaryCommands
      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:
      randomBinaryKey in interface KeyBinaryCommands
      Returns:
      The randomly selected key or an empty string is the database is empty
    • rename

      public String rename(byte[] oldkey, byte[] newkey)
      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:
      rename in interface KeyBinaryCommands
      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:
      renamenx in interface KeyBinaryCommands
      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:
      dbSize in interface DatabaseCommands
      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 PERSIST command.

      Time complexity: O(1)

      Specified by:
      expire in interface KeyBinaryCommands
      Parameters:
      key -
      seconds -
      Returns:
      1: the timeout was set. 0: the timeout was not set.
      See Also:
    • expire

      public long expire(byte[] key, long seconds, ExpiryOption expiryOption)
      Specified by:
      expire in interface KeyBinaryCommands
    • 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 PERSIST command.

      Time complexity: O(1)

      Specified by:
      pexpire in interface KeyBinaryCommands
      Parameters:
      key -
      milliseconds -
      Returns:
      1: the timeout was set. 0: the timeout was not set.
      See Also:
    • pexpire

      public long pexpire(byte[] key, long milliseconds, ExpiryOption expiryOption)
      Specified by:
      pexpire in interface KeyBinaryCommands
    • expireTime

      public long expireTime(byte[] key)
      Specified by:
      expireTime in interface KeyBinaryCommands
    • pexpireTime

      public long pexpireTime(byte[] key)
      Specified by:
      pexpireTime in interface KeyBinaryCommands
    • expireAt

      public long expireAt(byte[] key, long unixTime)
      EXPIREAT works exactly like EXPIRE but instead to get the number of seconds representing the Time To Live of the key as a second argument (that is a relative way of specifying the TTL), it takes an absolute one in the form of a UNIX timestamp (Number of seconds elapsed since 1 Gen 1970).

      EXPIREAT was introduced in order to implement the Append Only File persistence mode so that EXPIRE commands are automatically translated into EXPIREAT commands for the append only file. Of course EXPIREAT can also used by programmers that need a way to simply specify that a given key should expire at a given time in the future.

      Since Redis 2.1.3 you can update the value of the timeout of a key already having an expire set. It is also possible to undo the expire at all turning the key into a normal key using the PERSIST command.

      Time complexity: O(1)

      Specified by:
      expireAt in interface KeyBinaryCommands
      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

      public long expireAt(byte[] key, long unixTime, ExpiryOption expiryOption)
      Specified by:
      expireAt in interface KeyBinaryCommands
    • pexpireAt

      public long pexpireAt(byte[] key, long millisecondsTimestamp)
      Specified by:
      pexpireAt in interface KeyBinaryCommands
    • pexpireAt

      public long pexpireAt(byte[] key, long millisecondsTimestamp, ExpiryOption expiryOption)
      Specified by:
      pexpireAt in interface KeyBinaryCommands
    • ttl

      public long ttl(byte[] key)
      The TTL command returns the remaining time to live in seconds of a key that has an EXPIRE set. This introspection capability allows a Redis connection to check how many seconds a given key will continue to be part of the dataset.
      Specified by:
      ttl in interface KeyBinaryCommands
      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:
      touch in interface KeyBinaryCommands
      Parameters:
      keys -
      Returns:
      The number of keys that were touched.
    • touch

      public long touch(byte[] key)
      Specified by:
      touch in interface KeyBinaryCommands
    • 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:
      move in interface DatabaseCommands
      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:
      getSet in interface StringBinaryCommands
      Parameters:
      key -
      value -
      Returns:
      Bulk reply
    • mget

      public List<byte[]> mget(byte[]... keys)
      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:
      mget in interface StringBinaryCommands
      Parameters:
      keys -
      Returns:
      Multi bulk reply
    • setnx

      public long setnx(byte[] key, byte[] value)
      SETNX works exactly like SET with the only difference that if the key already exists no operation is performed. SETNX actually means "SET if Not eXists".

      Time complexity: O(1)

      Specified by:
      setnx in interface StringBinaryCommands
      Parameters:
      key -
      value -
      Returns:
      1 if the key was set 0 if the key was not set
    • setex

      public String setex(byte[] key, long seconds, byte[] value)
      The command is exactly equivalent to the following group of commands: SET + EXPIRE. The operation is atomic.

      Time complexity: O(1)

      Specified by:
      setex in interface StringBinaryCommands
      Parameters:
      key -
      seconds -
      value -
      Returns:
      OK
    • mset

      public String mset(byte[]... keysvalues)
      Set the the respective keys to the respective values. MSET will replace old values with new values, while MSETNX will not perform any operation at all even if just a single key already exists.

      Because of this semantic MSETNX can be used in order to set different keys representing different fields of an unique logic object in a way that ensures that either all the fields or none at all are set.

      Both MSET and MSETNX are atomic operations. This means that for instance if the keys A and B are modified, another connection talking to Redis can either see the changes to both A and B at once, or no modification at all.

      Specified by:
      mset in interface StringBinaryCommands
      Parameters:
      keysvalues -
      Returns:
      OK
      See Also:
    • msetnx

      public long msetnx(byte[]... keysvalues)
      Set the respective keys to the respective values. MSET will replace old values with new values, while MSETNX will not perform any operation at all even if just a single key already exists.

      Because of this semantic MSETNX can be used in order to set different keys representing different fields of an unique logic object in a way that ensures that either all the fields or none at all are set.

      Both MSET and MSETNX are atomic operations. This means that for instance if the keys A and B are modified, another connection talking to Redis can either see the changes to both A and B at once, or no modification at all.

      Specified by:
      msetnx in interface StringBinaryCommands
      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 like DECR but 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:
      decrBy in interface StringBinaryCommands
      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:
      decr in interface StringBinaryCommands
      Parameters:
      key -
      Returns:
      The value of key after the decrement
      See Also:
    • incrBy

      public long incrBy(byte[] key, long increment)
      INCRBY work just like INCR but instead to increment by 1 the increment is integer.

      INCR commands are limited to 64 bit signed integers.

      Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.

      Time complexity: O(1)

      Specified by:
      incrBy in interface StringBinaryCommands
      Parameters:
      key -
      increment -
      Returns:
      The value of key after the increment
      See Also:
    • incrByFloat

      public double incrByFloat(byte[] key, double increment)
      INCRBYFLOAT work just like incrBy(byte[], long) INCRBY} but increments by floats instead of integers.

      INCRBYFLOAT commands are limited to double precision floating point values.

      Note: this is actually a string operation, that is, in Redis there are not "double" types. Simply the string stored at the key is parsed as a base double precision floating point value, incremented, and then converted back as a string. There is no DECRYBYFLOAT but providing a negative value will work as expected.

      Time complexity: O(1)

      Specified by:
      incrByFloat in interface StringBinaryCommands
      Parameters:
      key - the key to increment
      increment - 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:
      incr in interface StringBinaryCommands
      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:
      append in interface StringBinaryCommands
      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:
      substr in interface StringBinaryCommands
      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:
      hset in interface HashBinaryCommands
      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

      public long hset(byte[] key, Map<byte[],byte[]> hash)
      Specified by:
      hset in interface HashBinaryCommands
    • 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:
      hget in interface HashBinaryCommands
      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:
      hsetnx in interface HashBinaryCommands
      Parameters:
      key -
      field -
      value -
      Returns:
      If the field already exists, 0 is returned, otherwise if a new field is created 1 is returned.
    • hmset

      public String hmset(byte[] key, Map<byte[],byte[]> hash)
      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:
      hmset in interface HashBinaryCommands
      Parameters:
      key -
      hash -
      Returns:
      OK
    • hmget

      public List<byte[]> hmget(byte[] key, byte[]... fields)
      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:
      hmget in interface HashBinaryCommands
      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:
      hincrBy in interface HashBinaryCommands
      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:
      hincrByFloat in interface HashBinaryCommands
      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:
      hexists in interface HashBinaryCommands
      Parameters:
      key -
      field -
      Returns:
      true if the hash stored at key contains the specified field, false if 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:
      hdel in interface HashBinaryCommands
      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:
      hlen in interface HashBinaryCommands
      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

      public Set<byte[]> hkeys(byte[] key)
      Return all the fields in a hash.

      Time complexity: O(N), where N is the total number of entries

      Specified by:
      hkeys in interface HashBinaryCommands
      Parameters:
      key -
      Returns:
      All the fields names contained into a hash.
    • hvals

      public List<byte[]> hvals(byte[] key)
      Return all the values in a hash.

      Time complexity: O(N), where N is the total number of entries

      Specified by:
      hvals in interface HashBinaryCommands
      Parameters:
      key -
      Returns:
      All the fields values contained into a hash.
    • hgetAll

      public Map<byte[],byte[]> hgetAll(byte[] key)
      Return all the fields and associated values in a hash.

      Time complexity: O(N), where N is the total number of entries

      Specified by:
      hgetAll in interface HashBinaryCommands
      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:
      hrandfield in interface HashBinaryCommands
      Parameters:
      key -
      Returns:
      one random field from a hash.
    • hrandfield

      public List<byte[]> hrandfield(byte[] key, long count)
      Get multiple random fields from a hash.

      Time complexity: O(N), where N is the number of fields returned

      Specified by:
      hrandfield in interface HashBinaryCommands
      Parameters:
      key -
      Returns:
      Multiple random fields from a hash.
    • hrandfieldWithValues

      public Map<byte[],byte[]> hrandfieldWithValues(byte[] key, long count)
      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:
      hrandfieldWithValues in interface HashBinaryCommands
      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:
      rpush in interface ListBinaryCommands
      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:
      lpush in interface ListBinaryCommands
      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:
      llen in interface ListBinaryCommands
      Parameters:
      key -
      Returns:
      The length of the list
    • lrange

      public List<byte[]> lrange(byte[] key, long start, long stop)
      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:
      lrange in interface ListBinaryCommands
      Parameters:
      key -
      start -
      stop -
      Returns:
      A list of elements in the specified range
    • ltrim

      public String ltrim(byte[] key, long start, long stop)
      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:
      ltrim in interface ListBinaryCommands
      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:
      lindex in interface ListBinaryCommands
      Parameters:
      key -
      index -
      Returns:
      The requested element
    • lset

      public String lset(byte[] key, long index, byte[] value)
      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:
      lset in interface ListBinaryCommands
      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:
      lrem in interface ListBinaryCommands
      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:
      lpop in interface ListBinaryCommands
      Parameters:
      key -
      Returns:
      Bulk reply
      See Also:
    • lpop

      public List<byte[]> lpop(byte[] key, int count)
      Specified by:
      lpop in interface ListBinaryCommands
    • lpos

      public Long lpos(byte[] key, byte[] element)
      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:
      lpos in interface ListBinaryCommands
      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

      public Long lpos(byte[] key, byte[] element, LPosParams params)
      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:
      lpos in interface ListBinaryCommands
      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

      public List<Long> lpos(byte[] key, byte[] element, LPosParams params, long count)
      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:
      lpos in interface ListBinaryCommands
      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:
      rpop in interface ListBinaryCommands
      Parameters:
      key -
      Returns:
      Bulk reply
      See Also:
    • rpop

      public List<byte[]> rpop(byte[] key, int count)
      Specified by:
      rpop in interface ListBinaryCommands
    • 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:
      rpoplpush in interface ListBinaryCommands
      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:
      sadd in interface SetBinaryCommands
      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

      public Set<byte[]> smembers(byte[] key)
      Return all the members (elements) of the set value stored at key. This is just syntax glue for sinter(byte[][]) SINTER}.

      Time complexity O(N)

      Specified by:
      smembers in interface SetBinaryCommands
      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:
      srem in interface SetBinaryCommands
      Parameters:
      key - the key of the set
      members - 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:
      spop in interface SetBinaryCommands
      Parameters:
      key -
      Returns:
      The removed member, or nil when key does not exist
    • spop

      public Set<byte[]> spop(byte[] key, long count)
      Specified by:
      spop in interface SetBinaryCommands
    • 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:
      smove in interface SetBinaryCommands
      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:
      scard in interface SetBinaryCommands
      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:
      sismember in interface SetBinaryCommands
      Parameters:
      key -
      member -
      Returns:
      true if the element is a member of the set, false otherwise
    • smismember

      public List<Boolean> smismember(byte[] key, byte[]... members)
      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:
      smismember in interface SetBinaryCommands
      Parameters:
      key -
      members -
      Returns:
      List representing the membership of the given elements, in the same order as they are requested
    • sinter

      public Set<byte[]> sinter(byte[]... keys)
      Return the members of a set resulting from the intersection of all the sets hold at the specified keys. Like in lrange(byte[], long, long) LRANGE} the result is sent to the connection as a multi-bulk reply (see the protocol specification for more information). If just a single key is specified, then this command produces the same result as SMEMBERS. Actually SMEMBERS is just syntax sugar for SINTER.

      Non existing keys are considered like empty sets, so if one of the keys is missing an empty set is returned (since the intersection with an empty set always is an empty set).

      Time complexity O(N*M) worst case where N is the cardinality of the smallest set and M the number of sets

      Specified by:
      sinter in interface SetBinaryCommands
      Parameters:
      keys -
      Returns:
      A set with members of the resulting set
    • sinterstore

      public long sinterstore(byte[] dstkey, byte[]... keys)
      This command works exactly like SINTER but instead of being returned the resulting set is stored as dstkey.

      Time complexity O(N*M) worst case where N is the cardinality of the smallest set and M the number of sets

      Specified by:
      sinterstore in interface SetBinaryCommands
      Parameters:
      dstkey -
      keys -
      Returns:
      The number of elements in the resulting set
    • sintercard

      public long sintercard(byte[]... keys)
      This command works exactly like SINTER but instead of returning the result set, it returns just the cardinality of the result. LIMIT defaults to 0 and means unlimited

      Time complexity O(N*M) worst case where N is the cardinality of the smallest

      Specified by:
      sintercard in interface SetBinaryCommands
      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 like SINTER but 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:
      sintercard in interface SetBinaryCommands
      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

      public Set<byte[]> sunion(byte[]... keys)
      Return the members of a set resulting from the union of all the sets hold at the specified keys. Like in lrange(byte[], long, long) LRANGE} the result is sent to the connection as a multi-bulk reply (see the protocol specification for more information). If just a single key is specified, then this command produces the same result as SMEMBERS.

      Non existing keys are considered like empty sets.

      Time complexity O(N) where N is the total number of elements in all the provided sets

      Specified by:
      sunion in interface SetBinaryCommands
      Parameters:
      keys -
      Returns:
      A set with members of the resulting set
    • sunionstore

      public long sunionstore(byte[] dstkey, byte[]... keys)
      This command works exactly like SUNION but instead of being returned the resulting set is stored as dstkey. Any existing value in dstkey will be over-written.

      Time complexity O(N) where N is the total number of elements in all the provided sets

      Specified by:
      sunionstore in interface SetBinaryCommands
      Parameters:
      dstkey -
      keys -
      Returns:
      The number of elements in the resulting set
    • sdiff

      public Set<byte[]> sdiff(byte[]... keys)
      Return the difference between the Set stored at key1 and all the Sets key2, ..., keyN

      Example:

       key1 = [x, a, b, c]
       key2 = [c]
       key3 = [a, d]
       SDIFF key1,key2,key3 => [x, b]
       
      Non existing keys are considered like empty sets.

      Time complexity:

      O(N) with N being the total number of elements of all the sets

      Specified by:
      sdiff in interface SetBinaryCommands
      Parameters:
      keys -
      Returns:
      A set with members of the resulting set
    • sdiffstore

      public long sdiffstore(byte[] dstkey, byte[]... keys)
      This command works exactly like SDIFF but instead of being returned the resulting set is stored in dstkey.
      Specified by:
      sdiffstore in interface SetBinaryCommands
      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:
      srandmember in interface SetBinaryCommands
      Parameters:
      key -
      Returns:
      The randomly selected element
    • srandmember

      public List<byte[]> srandmember(byte[] key, int count)
      Specified by:
      srandmember in interface SetBinaryCommands
    • 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:
      zadd in interface SortedSetBinaryCommands
      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

      public long zadd(byte[] key, double score, byte[] member, ZAddParams params)
      Specified by:
      zadd in interface SortedSetBinaryCommands
    • zadd

      public long zadd(byte[] key, Map<byte[],Double> scoreMembers)
      Specified by:
      zadd in interface SortedSetBinaryCommands
    • zadd

      public long zadd(byte[] key, Map<byte[],Double> scoreMembers, ZAddParams params)
      Specified by:
      zadd in interface SortedSetBinaryCommands
    • zaddIncr

      public Double zaddIncr(byte[] key, double score, byte[] member, ZAddParams params)
      Specified by:
      zaddIncr in interface SortedSetBinaryCommands
    • zrange

      public List<byte[]> zrange(byte[] key, long start, long stop)
      Specified by:
      zrange in interface SortedSetBinaryCommands
    • 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:
      zrem in interface SortedSetBinaryCommands
      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:
      zincrby in interface SortedSetBinaryCommands
      Parameters:
      key -
      increment -
      member -
      Returns:
      The new score
    • zincrby

      public Double zincrby(byte[] key, double increment, byte[] member, ZIncrByParams params)
      Specified by:
      zincrby in interface SortedSetBinaryCommands
    • zrank

      public Long zrank(byte[] key, byte[] member)
      Return the rank (or index) or member in the sorted set at key, with scores being ordered from low to high.

      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:
      zrank in interface SortedSetBinaryCommands
      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

      public Long zrevrank(byte[] key, byte[] member)
      Return the rank (or index) or member in the sorted set at key, with scores being ordered from high to low.

      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:
      zrevrank in interface SortedSetBinaryCommands
      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

      public KeyValue<Long,Double> 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.
      Specified by:
      zrankWithScore in interface SortedSetBinaryCommands
      Parameters:
      key - the key
      member - the member
      Returns:
      the KeyValue contains rank and score.
    • zrevrankWithScore

      public KeyValue<Long,Double> 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.
      Specified by:
      zrevrankWithScore in interface SortedSetBinaryCommands
      Parameters:
      key - the key
      member - the member
      Returns:
      the KeyValue contains rank and score.
    • zrevrange

      public List<byte[]> zrevrange(byte[] key, long start, long stop)
      Specified by:
      zrevrange in interface SortedSetBinaryCommands
    • zrangeWithScores

      public List<Tuple> zrangeWithScores(byte[] key, long start, long stop)
      Specified by:
      zrangeWithScores in interface SortedSetBinaryCommands
    • zrevrangeWithScores

      public List<Tuple> zrevrangeWithScores(byte[] key, long start, long stop)
      Specified by:
      zrevrangeWithScores in interface SortedSetBinaryCommands
    • zrange

      public List<byte[]> zrange(byte[] key, ZRangeParams zRangeParams)
      Specified by:
      zrange in interface SortedSetBinaryCommands
    • zrangeWithScores

      public List<Tuple> zrangeWithScores(byte[] key, ZRangeParams zRangeParams)
      Specified by:
      zrangeWithScores in interface SortedSetBinaryCommands
    • zrangestore

      public long zrangestore(byte[] dest, byte[] src, ZRangeParams zRangeParams)
      Specified by:
      zrangestore in interface SortedSetBinaryCommands
    • zrandmember

      public byte[] zrandmember(byte[] key)
      Specified by:
      zrandmember in interface SortedSetBinaryCommands
    • zrandmember

      public List<byte[]> zrandmember(byte[] key, long count)
      Specified by:
      zrandmember in interface SortedSetBinaryCommands
    • zrandmemberWithScores

      public List<Tuple> zrandmemberWithScores(byte[] key, long count)
      Specified by:
      zrandmemberWithScores in interface SortedSetBinaryCommands
    • 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:
      zcard in interface SortedSetBinaryCommands
      Parameters:
      key -
      Returns:
      The cardinality (number of elements) of the set as an integer.
    • zscore

      public Double zscore(byte[] key, byte[] member)
      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:
      zscore in interface SortedSetBinaryCommands
      Parameters:
      key -
      member -
      Returns:
      The score
    • zmscore

      public List<Double> zmscore(byte[] key, byte[]... members)
      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:
      zmscore in interface SortedSetBinaryCommands
      Parameters:
      key -
      members -
      Returns:
      The scores
    • zpopmax

      public Tuple zpopmax(byte[] key)
      Specified by:
      zpopmax in interface SortedSetBinaryCommands
    • zpopmax

      public List<Tuple> zpopmax(byte[] key, int count)
      Specified by:
      zpopmax in interface SortedSetBinaryCommands
    • zpopmin

      public Tuple zpopmin(byte[] key)
      Specified by:
      zpopmin in interface SortedSetBinaryCommands
    • zpopmin

      public List<Tuple> zpopmin(byte[] key, int count)
      Specified by:
      zpopmin in interface SortedSetBinaryCommands
    • watch

      public String watch(byte[]... keys)
    • unwatch

      public String unwatch()
    • sort

      public List<byte[]> sort(byte[] key)
      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:
      sort in interface KeyBinaryCommands
      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

      public List<byte[]> sort(byte[] key, SortingParams sortingParams)
      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:
      sort in interface KeyBinaryCommands
      Parameters:
      key -
      sortingParams -
      Returns:
      a list of sorted elements.
      See Also:
    • sort

      public long sort(byte[] key, SortingParams sortingParams, byte[] dstkey)
      Sort a Set or a List accordingly to the specified parameters and store the result at dstkey.
      Specified by:
      sort in interface KeyBinaryCommands
      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:
      sort in interface KeyBinaryCommands
      Parameters:
      key -
      dstkey -
      Returns:
      The number of elements of the list at dstkey.
      See Also:
    • sortReadonly

      public List<byte[]> sortReadonly(byte[] key, SortingParams sortingParams)
      Specified by:
      sortReadonly in interface KeyBinaryCommands
    • lmove

      public byte[] lmove(byte[] srcKey, byte[] dstKey, ListDirection from, ListDirection to)
      Pop an element from a list, push it to another list and return it
      Specified by:
      lmove in interface ListBinaryCommands
      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:
      blmove in interface ListBinaryCommands
      Parameters:
      srcKey -
      dstKey -
      from -
      to -
      timeout -
      Returns:
      The element being popped and pushed
    • blpop

      public List<byte[]> blpop(int timeout, byte[]... keys)
      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:
      blpop in interface ListBinaryCommands
      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

      public List<byte[]> blpop(double timeout, byte[]... keys)
      Specified by:
      blpop in interface ListBinaryCommands
    • brpop

      public List<byte[]> brpop(int timeout, byte[]... keys)
      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:
      brpop in interface ListBinaryCommands
      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

      public List<byte[]> brpop(double timeout, byte[]... keys)
      Specified by:
      brpop in interface ListBinaryCommands
    • lmpop

      public KeyValue<byte[],List<byte[]>> lmpop(ListDirection direction, byte[]... keys)
      Specified by:
      lmpop in interface ListBinaryCommands
    • lmpop

      public KeyValue<byte[],List<byte[]>> lmpop(ListDirection direction, int count, byte[]... keys)
      Specified by:
      lmpop in interface ListBinaryCommands
    • blmpop

      public KeyValue<byte[],List<byte[]>> blmpop(long timeout, ListDirection direction, byte[]... keys)
      Specified by:
      blmpop in interface ListBinaryCommands
    • blmpop

      public KeyValue<byte[],List<byte[]>> blmpop(long timeout, ListDirection direction, int count, byte[]... keys)
      Specified by:
      blmpop in interface ListBinaryCommands
    • bzpopmax

      public List<byte[]> bzpopmax(double timeout, byte[]... keys)
      Specified by:
      bzpopmax in interface SortedSetBinaryCommands
    • bzpopmin

      public List<byte[]> bzpopmin(double timeout, byte[]... keys)
      Specified by:
      bzpopmin in interface SortedSetBinaryCommands
    • auth

      public String auth(String password)
      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:
      auth in interface ServerCommands
      Parameters:
      password -
      Returns:
      OK
    • auth

      public String auth(String user, String password)
      Request for authentication with a Redis Server that is using ACL where user are authenticated with username and password. See https://redis.io/topics/acl
      Specified by:
      auth in interface ServerCommands
      Parameters:
      user -
      password -
      Returns:
      OK
    • zcount

      public long zcount(byte[] key, double min, double max)
      Specified by:
      zcount in interface SortedSetBinaryCommands
    • zcount

      public long zcount(byte[] key, byte[] min, byte[] max)
      Specified by:
      zcount in interface SortedSetBinaryCommands
    • zdiff

      public Set<byte[]> zdiff(byte[]... keys)
      Specified by:
      zdiff in interface SortedSetBinaryCommands
    • zdiffWithScores

      public Set<Tuple> zdiffWithScores(byte[]... keys)
      Specified by:
      zdiffWithScores in interface SortedSetBinaryCommands
    • zdiffStore

      public long zdiffStore(byte[] dstkey, byte[]... keys)
      Specified by:
      zdiffStore in interface SortedSetBinaryCommands
    • zrangeByScore

      public 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).

      The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).

      Using the optional LIMIT it 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 ZCOUNT command is similar to ZRANGEBYSCORE but instead of returning the actual elements in the specified interval, it just returns the number of matching elements.

      Exclusive intervals and infinity

      min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".

      Also while the interval is for default closed (inclusive) it is possible to specify open intervals prefixing the score with a "(" character, so for instance:

      ZRANGEBYSCORE zset (1.3 5

      Will return all the values with score > 1.3 and <= 5, while for instance:

      ZRANGEBYSCORE zset (5 (10

      Will return all the values with score > 5 and < 10 (5 and 10 excluded).

      Time complexity:

      O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))

      Specified by:
      zrangeByScore in interface SortedSetBinaryCommands
      Parameters:
      key -
      min -
      max -
      Returns:
      A list of elements in the specified score range
      See Also:
    • zrangeByScore

      public List<byte[]> zrangeByScore(byte[] key, byte[] min, byte[] max)
      Specified by:
      zrangeByScore in interface SortedSetBinaryCommands
    • zrangeByScore

      public 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).

      The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).

      Using the optional LIMIT it 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 ZCOUNT command is similar to ZRANGEBYSCORE but instead of returning the actual elements in the specified interval, it just returns the number of matching elements.

      Exclusive intervals and infinity

      min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".

      Also while the interval is for default closed (inclusive) it is possible to specify open intervals prefixing the score with a "(" character, so for instance:

      ZRANGEBYSCORE zset (1.3 5

      Will return all the values with score > 1.3 and <= 5, while for instance:

      ZRANGEBYSCORE zset (5 (10

      Will return all the values with score > 5 and < 10 (5 and 10 excluded).

      Time complexity:

      O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))

      Specified by:
      zrangeByScore in interface SortedSetBinaryCommands
      Parameters:
      key -
      min -
      max -
      offset -
      count -
      Returns:
      A list of elements in the specified score range
      See Also:
    • zrangeByScore

      public List<byte[]> zrangeByScore(byte[] key, byte[] min, byte[] max, int offset, int count)
      Specified by:
      zrangeByScore in interface SortedSetBinaryCommands
    • zrangeByScoreWithScores

      public List<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max)
      Return the all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max).

      The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).

      Using the optional LIMIT it 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 ZCOUNT command is similar to ZRANGEBYSCORE but instead of returning the actual elements in the specified interval, it just returns the number of matching elements.

      Exclusive intervals and infinity

      min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".

      Also while the interval is for default closed (inclusive) it is possible to specify open intervals prefixing the score with a "(" character, so for instance:

      ZRANGEBYSCORE zset (1.3 5

      Will return all the values with score > 1.3 and <= 5, while for instance:

      ZRANGEBYSCORE zset (5 (10

      Will return all the values with score > 5 and < 10 (5 and 10 excluded).

      Time complexity:

      O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))

      Specified by:
      zrangeByScoreWithScores in interface SortedSetBinaryCommands
      Parameters:
      key -
      min -
      max -
      Returns:
      A list of elements in the specified score range
      See Also:
    • zrangeByScoreWithScores

      public List<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max)
      Specified by:
      zrangeByScoreWithScores in interface SortedSetBinaryCommands
    • 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 LIMIT it 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 ZCOUNT command is similar to ZRANGEBYSCORE but instead of returning the actual elements in the specified interval, it just returns the number of matching elements.

      Exclusive intervals and infinity

      min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".

      Also while the interval is for default closed (inclusive) it is possible to specify open intervals prefixing the score with a "(" character, so for instance:

      ZRANGEBYSCORE zset (1.3 5

      Will return all the values with score > 1.3 and <= 5, while for instance:

      ZRANGEBYSCORE zset (5 (10

      Will return all the values with score > 5 and < 10 (5 and 10 excluded).

      Time complexity:

      O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))

      Specified by:
      zrangeByScoreWithScores in interface SortedSetBinaryCommands
      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:
      zrangeByScoreWithScores in interface SortedSetBinaryCommands
    • zrevrangeByScore

      public List<byte[]> zrevrangeByScore(byte[] key, double max, double min)
      Specified by:
      zrevrangeByScore in interface SortedSetBinaryCommands
    • zrevrangeByScore

      public List<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min)
      Specified by:
      zrevrangeByScore in interface SortedSetBinaryCommands
    • zrevrangeByScore

      public List<byte[]> zrevrangeByScore(byte[] key, double max, double min, int offset, int count)
      Specified by:
      zrevrangeByScore in interface SortedSetBinaryCommands
    • zrevrangeByScore

      public List<byte[]> zrevrangeByScore(byte[] key, byte[] max, byte[] min, int offset, int count)
      Specified by:
      zrevrangeByScore in interface SortedSetBinaryCommands
    • zrevrangeByScoreWithScores

      public List<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min)
      Specified by:
      zrevrangeByScoreWithScores in interface SortedSetBinaryCommands
    • zrevrangeByScoreWithScores

      public List<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min, int offset, int count)
      Specified by:
      zrevrangeByScoreWithScores in interface SortedSetBinaryCommands
    • zrevrangeByScoreWithScores

      public List<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min)
      Specified by:
      zrevrangeByScoreWithScores in interface SortedSetBinaryCommands
    • zrevrangeByScoreWithScores

      public List<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min, int offset, int count)
      Specified by:
      zrevrangeByScoreWithScores in interface SortedSetBinaryCommands
    • 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:
      zremrangeByRank in interface SortedSetBinaryCommands
      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:
      zremrangeByScore in interface SortedSetBinaryCommands
      Parameters:
      key -
      min -
      max -
      Returns:
      The number of elements removed
    • zremrangeByScore

      public long zremrangeByScore(byte[] key, byte[] min, byte[] max)
      Specified by:
      zremrangeByScore in interface SortedSetBinaryCommands
    • zunion

      public Set<byte[]> zunion(ZParams params, byte[]... keys)
      Add multiple sorted sets, This command is similar to ZUNIONSTORE, but instead of storing the resulting sorted set, it is returned to the connection.
      Specified by:
      zunion in interface SortedSetBinaryCommands
      Parameters:
      params -
      keys -
      Returns:
      The result of the union
    • zunionWithScores

      public Set<Tuple> zunionWithScores(ZParams params, byte[]... keys)
      Add multiple sorted sets with scores, This command is similar to ZUNIONSTORE, but instead of storing the resulting sorted set, it is returned to the connection.
      Specified by:
      zunionWithScores in interface SortedSetBinaryCommands
      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. The zunionstore(byte[], byte[][]) command inserts all elements across all inputs.

      Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.

      With the AGGREGATE option, it 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:
      zunionstore in interface SortedSetBinaryCommands
      Parameters:
      dstkey -
      sets -
      Returns:
      The number of elements in the sorted set at dstkey
    • zunionstore

      public long zunionstore(byte[] dstkey, ZParams params, byte[]... sets)
      Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. 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 command requires an element to be present in each of the given inputs to be inserted in the result. The ZUNIONSTORE command inserts all elements across all inputs.

      Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.

      With the AGGREGATE option, it 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:
      zunionstore in interface SortedSetBinaryCommands
      Parameters:
      dstkey -
      params -
      sets -
      Returns:
      The number of elements in the sorted set at dstkey
    • zinter

      public Set<byte[]> zinter(ZParams params, byte[]... keys)
      Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the connection.
      Specified by:
      zinter in interface SortedSetBinaryCommands
      Parameters:
      params -
      keys -
      Returns:
      The result of the intersection
    • zinterWithScores

      public Set<Tuple> zinterWithScores(ZParams params, byte[]... keys)
      Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the connection.
      Specified by:
      zinterWithScores in interface SortedSetBinaryCommands
      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 ZINTERSTORE command requires an element to be present in each of the given inputs to be inserted in the result. The ZUNIONSTORE command inserts all elements across all inputs.

      Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.

      With the AGGREGATE option, it 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:
      zinterstore in interface SortedSetBinaryCommands
      Parameters:
      dstkey -
      sets -
      Returns:
      The number of elements in the sorted set at dstkey
    • zinterstore

      public long zinterstore(byte[] dstkey, ZParams params, byte[]... sets)
      Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. 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 command requires an element to be present in each of the given inputs to be inserted in the result. The ZUNIONSTORE command inserts all elements across all inputs.

      Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.

      With the AGGREGATE option, it 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:
      zinterstore in interface SortedSetBinaryCommands
      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: SortedSetBinaryCommands
      Similar to ZINTER, 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:
      zintercard in interface SortedSetBinaryCommands
      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: SortedSetBinaryCommands
      Similar to ZINTER, 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:
      zintercard in interface SortedSetBinaryCommands
      Parameters:
      limit - If the intersection cardinality reaches limit partway through the computation, the algorithm will exit and yield limit as the cardinality
      keys - 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:
      zlexcount in interface SortedSetBinaryCommands
    • zrangeByLex

      public List<byte[]> zrangeByLex(byte[] key, byte[] min, byte[] max)
      Specified by:
      zrangeByLex in interface SortedSetBinaryCommands
    • zrangeByLex

      public List<byte[]> zrangeByLex(byte[] key, byte[] min, byte[] max, int offset, int count)
      Specified by:
      zrangeByLex in interface SortedSetBinaryCommands
    • zrevrangeByLex

      public List<byte[]> zrevrangeByLex(byte[] key, byte[] max, byte[] min)
      Specified by:
      zrevrangeByLex in interface SortedSetBinaryCommands
    • zrevrangeByLex

      public List<byte[]> zrevrangeByLex(byte[] key, byte[] max, byte[] min, int offset, int count)
      Specified by:
      zrevrangeByLex in interface SortedSetBinaryCommands
    • zremrangeByLex

      public long zremrangeByLex(byte[] key, byte[] min, byte[] max)
      Specified by:
      zremrangeByLex in interface SortedSetBinaryCommands
    • zmpop

      public KeyValue<byte[],List<Tuple>> zmpop(SortedSetOption option, byte[]... keys)
      Specified by:
      zmpop in interface SortedSetBinaryCommands
    • zmpop

      public KeyValue<byte[],List<Tuple>> zmpop(SortedSetOption option, int count, byte[]... keys)
      Specified by:
      zmpop in interface SortedSetBinaryCommands
    • bzmpop

      public KeyValue<byte[],List<Tuple>> bzmpop(long timeout, SortedSetOption option, byte[]... keys)
      Specified by:
      bzmpop in interface SortedSetBinaryCommands
    • bzmpop

      public KeyValue<byte[],List<Tuple>> bzmpop(long timeout, SortedSetOption option, int count, byte[]... keys)
      Specified by:
      bzmpop in interface SortedSetBinaryCommands
    • save

      public String 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 BGSAVE that is able to perform the saving in the background while the server continues serving other clients.

      Specified by:
      save in interface ServerCommands
      Returns:
      OK
    • bgsave

      public String 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:
      bgsave in interface ServerCommands
      Returns:
      OK
    • bgsaveSchedule

      public String bgsaveSchedule()
      Specified by:
      bgsaveSchedule in interface ServerCommands
    • bgrewriteaof

      public String 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:
      bgrewriteaof in interface ServerCommands
      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 BGSAVE command succeeded reading the LASTSAVE value, then issuing a BGSAVE command and checking at regular intervals every N seconds if LASTSAVE changed.

      Specified by:
      lastsave in interface ServerCommands
      Returns:
      An UNIX time stamp
    • shutdown

      public void shutdown() throws JedisException
      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 SAVE and then QUIT because other clients may alter the DB data between the two commands.

      Specified by:
      shutdown in interface ServerCommands
      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 public void shutdown(SaveMode saveMode) throws JedisException
      Specified by:
      shutdown in interface ServerCommands
      Parameters:
      saveMode - modifier to alter the data save behavior of SHUTDOWN. null would trigger the default behavior.
      Throws:
      JedisException
      See Also:
    • shutdown

      public void shutdown(ShutdownParams shutdownParams) throws JedisException
      Specified by:
      shutdown in interface ServerCommands
      Parameters:
      shutdownParams - set commands parameters
      Throws:
      JedisException
      See Also:
    • shutdownAbort

      public String shutdownAbort()
      Specified by:
      shutdownAbort in interface ServerCommands
    • info

      public String 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
       
      Notes

      used_memory is returned in bytes, and is the total number of bytes allocated by the program using malloc.

      uptime_in_days is redundant since the uptime in seconds contains already the full uptime information, this field is only mainly present for humans.

      changes_since_last_save does not refer to the number of key changes, but to the number of operations that produced some kind of change in the dataset.

      Specified by:
      info in interface ServerCommands
      Returns:
      Bulk reply
    • info

      public String info(String section)
      Description copied from interface: ServerCommands
      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.
      Specified by:
      info in interface ServerCommands
      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

      public void monitor(JedisMonitor jedisMonitor)
      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 public String slaveof(String host, int port)
      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:
      slaveof in interface ServerCommands
      Parameters:
      host -
      port -
      Returns:
      OK
    • slaveofNoOne

      @Deprecated public String slaveofNoOne()
      Deprecated.
      Description copied from interface: ServerCommands
      SLAVEOF 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:
      slaveofNoOne in interface ServerCommands
      Returns:
      result of the command
    • replicaof

      public String replicaof(String host, int port)
      Description copied from interface: ServerCommands
      The 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:
      replicaof in interface ServerCommands
      Parameters:
      host - listening at the specified hostname
      port - server listening at the specified port
      Returns:
      result of the command.
    • replicaofNoOne

      public String replicaofNoOne()
      Description copied from interface: ServerCommands
      REPLICAOF 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:
      replicaofNoOne in interface ServerCommands
      Returns:
      result of the command
    • roleBinary

      public List<Object> roleBinary()
      Description copied from interface: ControlBinaryCommands
      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. 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:
      roleBinary in interface ControlBinaryCommands
      Returns:
      The information on the role of a Redis instance
    • configGet

      public List<byte[]> configGet(byte[] pattern)
      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:
      configGet in interface ConfigCommands
      Parameters:
      pattern -
      Returns:
      Bulk reply.
    • configGet

      public List<byte[]> configGet(byte[]... patterns)
      Description copied from interface: ConfigCommands
      Used to read the configuration parameters of Redis server.
      Specified by:
      configGet in interface ConfigCommands
      Parameters:
      patterns - names of Redis server's configuration
      Returns:
      values of Redis server's configuration
    • configResetStat

      public String configResetStat()
      Reset the stats returned by INFO
      Specified by:
      configResetStat in interface ConfigCommands
      Returns:
      always OK.
    • configRewrite

      public String configRewrite()
      The CONFIG REWRITE command rewrites the redis.conf file the server was started with, applying the minimal changes needed to make it reflect the configuration currently used by the server, which may be different compared to the original one because of the use of the CONFIG SET command.

      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:
      configRewrite in interface ConfigCommands
      Returns:
      OK when the configuration was rewritten properly. Otherwise an error is returned.
    • configSet

      public String configSet(byte[] parameter, byte[] value)
      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:
      configSet in interface ConfigCommands
      Parameters:
      parameter -
      value -
      Returns:
      OK
    • configSet

      public String configSet(byte[]... parameterValues)
      Specified by:
      configSet in interface ConfigCommands
    • strlen

      public long strlen(byte[] key)
      Specified by:
      strlen in interface StringBinaryCommands
    • strAlgoLCSKeys

      @Deprecated public LCSMatchResult strAlgoLCSKeys(byte[] keyA, byte[] keyB, StrAlgoLCSParams params)
      Deprecated.
      STRALGO LCS command will be removed from Redis 7. LCS can be used instead of this method.
      Specified by:
      strAlgoLCSKeys in interface StringBinaryCommands
    • strAlgoLCSStrings

      @Deprecated public LCSMatchResult strAlgoLCSStrings(byte[] strA, byte[] strB, StrAlgoLCSParams params)
      Deprecated.
      STRALGO LCS command will be removed from Redis 7.
    • lcs

      public LCSMatchResult lcs(byte[] keyA, byte[] keyB, LCSParams params)
      Description copied from interface: StringBinaryCommands
      Calculate the longest common subsequence of keyA and keyB.
      Specified by:
      lcs in interface StringBinaryCommands
      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:
      lpushx in interface ListBinaryCommands
    • persist

      public long persist(byte[] key)
      Undo a expire at turning the expire key into a normal key.

      Time complexity: O(1)

      Specified by:
      persist in interface KeyBinaryCommands
      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:
      rpushx in interface ListBinaryCommands
    • echo

      public byte[] echo(byte[] string)
      Specified by:
      echo in interface ServerCommands
    • linsert

      public long linsert(byte[] key, ListPosition where, byte[] pivot, byte[] value)
      Specified by:
      linsert in interface ListBinaryCommands
    • 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:
      brpoplpush in interface ListBinaryCommands
    • 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:
      setbit in interface BitBinaryCommands
    • getbit

      public boolean getbit(byte[] key, long offset)
      Returns the bit value at offset in the string value stored at key
      Specified by:
      getbit in interface BitBinaryCommands
    • bitpos

      public long bitpos(byte[] key, boolean value)
      Specified by:
      bitpos in interface BitBinaryCommands
    • bitpos

      public long bitpos(byte[] key, boolean value, BitPosParams params)
      Specified by:
      bitpos in interface BitBinaryCommands
    • setrange

      public long setrange(byte[] key, long offset, byte[] value)
      Specified by:
      setrange in interface StringBinaryCommands
    • getrange

      public byte[] getrange(byte[] key, long startOffset, long endOffset)
      Specified by:
      getrange in interface StringBinaryCommands
    • publish

      public long publish(byte[] channel, byte[] message)
    • subscribe

      public void subscribe(BinaryJedisPubSub jedisPubSub, byte[]... channels)
    • psubscribe

      public void psubscribe(BinaryJedisPubSub jedisPubSub, byte[]... patterns)
    • eval

      public Object eval(byte[] script, List<byte[]> keys, List<byte[]> args)
      Evaluates scripts using the Lua interpreter built into Redis starting from version 2.6.0.
      Specified by:
      eval in interface ScriptingKeyBinaryCommands
      Parameters:
      script -
      keys -
      args -
      Returns:
      Script result
    • evalReadonly

      public Object evalReadonly(byte[] script, List<byte[]> keys, List<byte[]> args)
      Specified by:
      evalReadonly in interface ScriptingKeyBinaryCommands
    • getParamsWithBinary

      protected static byte[][] getParamsWithBinary(List<byte[]> keys, List<byte[]> args)
    • eval

      public Object eval(byte[] script, int keyCount, byte[]... params)
      Specified by:
      eval in interface ScriptingKeyBinaryCommands
    • eval

      public Object eval(byte[] script)
      Specified by:
      eval in interface ScriptingKeyBinaryCommands
    • evalsha

      public Object evalsha(byte[] sha1)
      Specified by:
      evalsha in interface ScriptingKeyBinaryCommands
    • evalsha

      public Object evalsha(byte[] sha1, List<byte[]> keys, List<byte[]> args)
      Specified by:
      evalsha in interface ScriptingKeyBinaryCommands
    • evalshaReadonly

      public Object evalshaReadonly(byte[] sha1, List<byte[]> keys, List<byte[]> args)
      Specified by:
      evalshaReadonly in interface ScriptingKeyBinaryCommands
    • evalsha

      public Object evalsha(byte[] sha1, int keyCount, byte[]... params)
      Specified by:
      evalsha in interface ScriptingKeyBinaryCommands
    • scriptFlush

      public String scriptFlush()
      Specified by:
      scriptFlush in interface ScriptingControlCommands
    • scriptFlush

      public String scriptFlush(FlushMode flushMode)
      Specified by:
      scriptFlush in interface ScriptingControlCommands
    • scriptExists

      public Boolean scriptExists(byte[] sha1)
      Specified by:
      scriptExists in interface ScriptingControlCommands
    • scriptExists

      public List<Boolean> scriptExists(byte[]... sha1)
      Specified by:
      scriptExists in interface ScriptingControlCommands
    • scriptLoad

      public byte[] scriptLoad(byte[] script)
      Specified by:
      scriptLoad in interface ScriptingControlCommands
    • scriptKill

      public String scriptKill()
      Specified by:
      scriptKill in interface ScriptingControlCommands
    • slowlogReset

      public String slowlogReset()
      Specified by:
      slowlogReset in interface SlowlogCommands
    • slowlogLen

      public long slowlogLen()
      Specified by:
      slowlogLen in interface SlowlogCommands
    • slowlogGetBinary

      public List<Object> slowlogGetBinary()
      Specified by:
      slowlogGetBinary in interface SlowlogCommands
    • slowlogGetBinary

      public List<Object> slowlogGetBinary(long entries)
      Specified by:
      slowlogGetBinary in interface SlowlogCommands
    • objectRefcount

      public Long objectRefcount(byte[] key)
      Description copied from interface: ControlBinaryCommands
      Returns the reference count of the stored at key.
      Specified by:
      objectRefcount in interface ControlBinaryCommands
      Specified by:
      objectRefcount in interface KeyBinaryCommands
      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: ControlBinaryCommands
      Returns the internal encoding for the Redis object stored at key.

      See for details: OBJECT ENCODING key

      Specified by:
      objectEncoding in interface ControlBinaryCommands
      Specified by:
      objectEncoding in interface KeyBinaryCommands
      Parameters:
      key - The key in Redis server
      Returns:
      The number of references
    • objectIdletime

      public Long objectIdletime(byte[] key)
      Description copied from interface: ControlBinaryCommands
      Returns the time in seconds since the last access to the value stored at key. The command is only available when the maxmemory-policy configuration directive is not set to one of the LFU policies.
      Specified by:
      objectIdletime in interface ControlBinaryCommands
      Specified by:
      objectIdletime in interface KeyBinaryCommands
      Parameters:
      key - The key in Redis server
      Returns:
      The idle time in seconds
    • objectHelpBinary

      public List<byte[]> objectHelpBinary()
      Description copied from interface: ControlBinaryCommands
      Returns the object subcommands and usages.
      Specified by:
      objectHelpBinary in interface ControlBinaryCommands
      Returns:
      object subcommands and usages
    • objectFreq

      public Long objectFreq(byte[] key)
      Description copied from interface: ControlBinaryCommands
      Returns the logarithmic access frequency counter of a Redis object stored at key.

      The command is only available when the maxmemory-policy configuration directive is set to one of the LFU policies.

      Specified by:
      objectFreq in interface ControlBinaryCommands
      Specified by:
      objectFreq in interface KeyBinaryCommands
      Parameters:
      key - The key in Redis server
      Returns:
      The counter's value
    • bitcount

      public long bitcount(byte[] key)
      Specified by:
      bitcount in interface BitBinaryCommands
    • bitcount

      public long bitcount(byte[] key, long start, long end)
      Specified by:
      bitcount in interface BitBinaryCommands
    • bitcount

      public long bitcount(byte[] key, long start, long end, BitCountOption option)
      Specified by:
      bitcount in interface BitBinaryCommands
    • bitop

      public long bitop(BitOP op, byte[] destKey, byte[]... srcKeys)
      Specified by:
      bitop in interface BitBinaryCommands
    • dump

      public byte[] dump(byte[] key)
      Specified by:
      dump in interface KeyBinaryCommands
    • restore

      public String restore(byte[] key, long ttl, byte[] serializedValue)
      Specified by:
      restore in interface KeyBinaryCommands
    • restore

      public String restore(byte[] key, long ttl, byte[] serializedValue, RestoreParams params)
      Specified by:
      restore in interface KeyBinaryCommands
    • pttl

      public long pttl(byte[] key)
      Specified by:
      pttl in interface KeyBinaryCommands
    • psetex

      public String psetex(byte[] key, long milliseconds, byte[] value)
      PSETEX works exactly like setex(byte[], long, byte[]) with the sole difference that the expire time is specified in milliseconds instead of seconds. Time complexity: O(1)
      Specified by:
      psetex in interface StringBinaryCommands
      Parameters:
      key -
      milliseconds -
      value -
      Returns:
      OK
    • memoryDoctorBinary

      public byte[] memoryDoctorBinary()
      Description copied from interface: ControlBinaryCommands
      Reports about different memory-related issues that the Redis server experiences, and advises about possible remedies.
      Specified by:
      memoryDoctorBinary in interface ControlBinaryCommands
    • memoryUsage

      public Long memoryUsage(byte[] key)
      Description copied from interface: ControlBinaryCommands
      Reports 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:
      memoryUsage in interface ControlBinaryCommands
      Specified by:
      memoryUsage in interface KeyBinaryCommands
      Parameters:
      key - The key in Redis server
      Returns:
      The memory usage in bytes, or nil when the key does not exist
    • memoryUsage

      public Long memoryUsage(byte[] key, int samples)
      Description copied from interface: ControlBinaryCommands
      Reports 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:
      memoryUsage in interface ControlBinaryCommands
      Specified by:
      memoryUsage in interface KeyBinaryCommands
      Parameters:
      key - The key in Redis server
      Returns:
      The memory usage in bytes, or nil when the key does not exist
    • failover

      public String failover()
      Specified by:
      failover in interface GenericControlCommands
    • failover

      public String failover(FailoverParams failoverParams)
      Specified by:
      failover in interface GenericControlCommands
    • failoverAbort

      public String failoverAbort()
      Specified by:
      failoverAbort in interface GenericControlCommands
    • aclWhoAmIBinary

      public byte[] aclWhoAmIBinary()
      Description copied from interface: AccessControlLogBinaryCommands
      Returns the username used to authenticate the current connection.
      Specified by:
      aclWhoAmIBinary in interface AccessControlLogBinaryCommands
      Returns:
      The username used for the current connection
      See Also:
    • aclGenPassBinary

      public byte[] aclGenPassBinary()
      Description copied from interface: AccessControlLogBinaryCommands
      Generate a random password
      Specified by:
      aclGenPassBinary in interface AccessControlLogBinaryCommands
      Returns:
      A random password
      See Also:
    • aclGenPassBinary

      public byte[] aclGenPassBinary(int bits)
      Description copied from interface: AccessControlLogBinaryCommands
      Generate a random password
      Specified by:
      aclGenPassBinary in interface AccessControlLogBinaryCommands
      Parameters:
      bits - the number of output bits
      Returns:
      A random password
    • aclListBinary

      public List<byte[]> aclListBinary()
      Description copied from interface: AccessControlLogBinaryCommands
      Returns the currently active ACL rules on the Redis Server
      Specified by:
      aclListBinary in interface AccessControlLogBinaryCommands
      Returns:
      An array of ACL rules
      See Also:
    • aclUsersBinary

      public List<byte[]> aclUsersBinary()
      Description copied from interface: AccessControlLogBinaryCommands
      Shows a list of all usernames currently configured with access control lists (ACL).
      Specified by:
      aclUsersBinary in interface AccessControlLogBinaryCommands
      Returns:
      list of users
      See Also:
    • aclGetUser

      public AccessControlUser aclGetUser(byte[] name)
      Description copied from interface: AccessControlLogBinaryCommands
      The command returns all the rules defined for an existing ACL user.
      Specified by:
      aclGetUser in interface AccessControlLogBinaryCommands
      Parameters:
      name - username
      Returns:
      a list of ACL rule definitions for the user.
    • aclSetUser

      public String aclSetUser(byte[] name)
      Description copied from interface: AccessControlLogBinaryCommands
      Create an ACL for the specified user with the default rules.
      Specified by:
      aclSetUser in interface AccessControlLogBinaryCommands
      Parameters:
      name - user who receives an acl
      Returns:
      A string containing OK on success
      See Also:
    • aclSetUser

      public String aclSetUser(byte[] name, byte[]... keys)
      Description copied from interface: AccessControlLogBinaryCommands
      Create an ACL for the specified user, while specifying the rules.
      Specified by:
      aclSetUser in interface AccessControlLogBinaryCommands
      Parameters:
      name - user who receives an acl
      keys - 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: AccessControlLogBinaryCommands
      Delete the specified user, from the ACL.
      Specified by:
      aclDelUser in interface AccessControlLogBinaryCommands
      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: AccessControlLogBinaryCommands
      Delete the specified users, from the ACL.
      Specified by:
      aclDelUser in interface AccessControlLogBinaryCommands
      Parameters:
      name - The username to delete
      names - Other usernames to delete
      Returns:
      The number of users delete
      See Also:
    • aclCatBinary

      public List<byte[]> aclCatBinary()
      Description copied from interface: AccessControlLogBinaryCommands
      Show the available ACL categories.
      Specified by:
      aclCatBinary in interface AccessControlLogBinaryCommands
      Returns:
      the available ACL categories
      See Also:
    • aclCat

      public List<byte[]> aclCat(byte[] category)
      Description copied from interface: AccessControlLogBinaryCommands
      Show the available ACLs for a given category.
      Specified by:
      aclCat in interface AccessControlLogBinaryCommands
      Parameters:
      category - The category for which to list available ACLs
      Returns:
      the available ACL categories
      See Also:
    • aclLogBinary

      public List<byte[]> aclLogBinary()
      Description copied from interface: AccessControlLogBinaryCommands
      Shows the recent ACL security events.
      Specified by:
      aclLogBinary in interface AccessControlLogBinaryCommands
      Returns:
      The list of recent security events
      See Also:
    • aclLogBinary

      public List<byte[]> aclLogBinary(int limit)
      Description copied from interface: AccessControlLogBinaryCommands
      Shows the recent limit ACL security events.
      Specified by:
      aclLogBinary in interface AccessControlLogBinaryCommands
      Parameters:
      limit - The number of results to return
      Returns:
      The list of recent security events
      See Also:
    • aclLogReset

      public String aclLogReset()
      Description copied from interface: AccessControlLogCommands
      Reset the script event log
      Specified by:
      aclLogReset in interface AccessControlLogBinaryCommands
      Specified by:
      aclLogReset in interface AccessControlLogCommands
      Returns:
      The OK string
      See Also:
    • clientKill

      public String clientKill(byte[] ipPort)
      Description copied from interface: ClientBinaryCommands
      Close a given client connection.
      Specified by:
      clientKill in interface ClientBinaryCommands
      Parameters:
      ipPort - The ip:port should match a line returned by the CLIENT LIST command (addr field).
      Returns:
      close success return OK
    • clientKill

      public String clientKill(String ip, int port)
      Description copied from interface: ClientCommands
      Close a given client connection.
      Specified by:
      clientKill in interface ClientBinaryCommands
      Specified by:
      clientKill in interface ClientCommands
      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

      public long clientKill(ClientKillParams params)
      Description copied from interface: ClientCommands
      Close a given client connection.
      Specified by:
      clientKill in interface ClientBinaryCommands
      Specified by:
      clientKill in interface ClientCommands
      Parameters:
      params - Connection info will be closed
      Returns:
      Close success return OK
    • clientGetnameBinary

      public byte[] clientGetnameBinary()
      Description copied from interface: ClientBinaryCommands
      Returns the name of the current connection as set by CLIENT SETNAME
      Specified by:
      clientGetnameBinary in interface ClientBinaryCommands
      Returns:
      Current connect name
    • clientListBinary

      public byte[] clientListBinary()
      Description copied from interface: ClientBinaryCommands
      Returns information and statistics about the client connections server in a mostly human readable format.
      Specified by:
      clientListBinary in interface ClientBinaryCommands
      Returns:
      All clients info connected to redis-server
    • clientListBinary

      public byte[] clientListBinary(ClientType type)
      Description copied from interface: ClientBinaryCommands
      Returns information and statistics about the client connections server in a mostly human readable format filter by client type.
      Specified by:
      clientListBinary in interface ClientBinaryCommands
      Returns:
      all clients info connected to redis-server
    • clientListBinary

      public byte[] clientListBinary(long... clientIds)
      Description copied from interface: ClientBinaryCommands
      Returns information and statistics about the client connections server in a mostly human readable format filter by client ids.
      Specified by:
      clientListBinary in interface ClientBinaryCommands
      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: ClientBinaryCommands
      Returns information and statistics about the current client connection in a mostly human readable format.
      Specified by:
      clientInfoBinary in interface ClientBinaryCommands
      Returns:
      Information and statistics about the current client connection
    • clientSetInfo

      public String clientSetInfo(ClientAttributeOption attr, byte[] value)
      Description copied from interface: ClientBinaryCommands
      client set info command Since redis 7.2
      Specified by:
      clientSetInfo in interface ClientBinaryCommands
      Parameters:
      attr - the attr option
      value - the value
      Returns:
      OK or error
    • clientSetname

      public String clientSetname(byte[] name)
      Description copied from interface: ClientBinaryCommands
      Assigns a name to the current connection.
      Specified by:
      clientSetname in interface ClientBinaryCommands
      Parameters:
      name - Current connection name
      Returns:
      OK if the connection name was successfully set.
    • clientId

      public long clientId()
      Description copied from interface: ClientCommands
      Returns the ID of the current connection.
      Specified by:
      clientId in interface ClientBinaryCommands
      Specified by:
      clientId in interface ClientCommands
      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:
      clientUnblock in interface ClientBinaryCommands
      Specified by:
      clientUnblock in interface ClientCommands
      Parameters:
      clientId -
      Returns:
      1 if the client was unblocked successfully, 0 if the client wasn't unblocked.
    • clientUnblock

      public long clientUnblock(long clientId, UnblockType unblockType)
      Unblock a connection blocked in a blocking command from a different connection.
      Specified by:
      clientUnblock in interface ClientBinaryCommands
      Specified by:
      clientUnblock in interface ClientCommands
      Parameters:
      clientId -
      unblockType -
      Returns:
      1 if the client was unblocked successfully, 0 if the client wasn't unblocked.
    • clientPause

      public String clientPause(long timeout)
      Description copied from interface: ClientCommands
      A connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds)
      Specified by:
      clientPause in interface ClientBinaryCommands
      Specified by:
      clientPause in interface ClientCommands
      Parameters:
      timeout - WRITE|ALL
      Returns:
      The command returns OK or an error if the timeout is invalid.
    • clientPause

      public String clientPause(long timeout, ClientPauseMode mode)
      Description copied from interface: ClientCommands
      A connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds)
      Specified by:
      clientPause in interface ClientBinaryCommands
      Specified by:
      clientPause in interface ClientCommands
      Parameters:
      timeout - Command timeout
      mode - WRITE|ALL
      Returns:
      The command returns OK or an error if the timeout is invalid.
    • clientUnpause

      public String clientUnpause()
      Description copied from interface: ClientCommands
      CLIENT UNPAUSE is used to resume command processing for all clients that were paused by CLIENT PAUSE.
      Specified by:
      clientUnpause in interface ClientBinaryCommands
      Specified by:
      clientUnpause in interface ClientCommands
      Returns:
      OK
    • clientNoEvictOn

      public String clientNoEvictOn()
      Description copied from interface: ClientCommands
      Turn on the client eviction mode for the current connection.
      Specified by:
      clientNoEvictOn in interface ClientBinaryCommands
      Specified by:
      clientNoEvictOn in interface ClientCommands
      Returns:
      OK
    • clientNoEvictOff

      public String clientNoEvictOff()
      Description copied from interface: ClientCommands
      Turn off the client eviction mode for the current connection.
      Specified by:
      clientNoEvictOff in interface ClientBinaryCommands
      Specified by:
      clientNoEvictOff in interface ClientCommands
      Returns:
      OK
    • clientNoTouchOn

      public String clientNoTouchOn()
      Description copied from interface: ClientCommands
      Specified by:
      clientNoTouchOn in interface ClientCommands
      Returns:
      OK
    • clientNoTouchOff

      public String clientNoTouchOff()
      Description copied from interface: ClientCommands
      Specified by:
      clientNoTouchOff in interface ClientCommands
      Returns:
      OK
    • time

      public List<String> time()
    • migrate

      public String migrate(String host, int port, byte[] key, int destinationDb, int timeout)
      Description copied from interface: DatabaseCommands
      Binary version of MIGRATE.
      Specified by:
      migrate in interface DatabaseCommands
      See Also:
    • migrate

      public String migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, byte[]... keys)
      Description copied from interface: DatabaseCommands
      Binary version of MIGRATE.
      Specified by:
      migrate in interface DatabaseCommands
      See Also:
    • migrate

      public String migrate(String host, int port, byte[] key, int timeout)
      Specified by:
      migrate in interface KeyBinaryCommands
    • migrate

      public String migrate(String host, int port, int timeout, MigrateParams params, byte[]... keys)
      Specified by:
      migrate in interface KeyBinaryCommands
    • waitReplicas

      public long waitReplicas(int replicas, long timeout)
      Description copied from interface: ServerCommands
      Synchronous 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 wait method, we cannot use it.

      Specified by:
      waitReplicas in interface ServerCommands
      Parameters:
      replicas - successfully transferred and acknowledged by at least the specified number of replicas
      timeout - 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

      public KeyValue<Long,Long> waitAOF(long numLocal, long numReplicas, long timeout)
      Description copied from interface: ServerCommands
      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. Redis Documentation
      Specified by:
      waitAOF in interface ServerCommands
      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 enabled
      numReplicas - Number of replicas that are required to acknowledge the sync
      timeout - 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:
      pfadd in interface HyperLogLogBinaryCommands
    • pfcount

      public long pfcount(byte[] key)
      Specified by:
      pfcount in interface HyperLogLogBinaryCommands
    • pfmerge

      public String pfmerge(byte[] destkey, byte[]... sourcekeys)
      Specified by:
      pfmerge in interface HyperLogLogBinaryCommands
    • pfcount

      public long pfcount(byte[]... keys)
      Specified by:
      pfcount in interface HyperLogLogBinaryCommands
    • scan

      public ScanResult<byte[]> scan(byte[] cursor)
      Specified by:
      scan in interface KeyBinaryCommands
    • scan

      public ScanResult<byte[]> scan(byte[] cursor, ScanParams params)
      Specified by:
      scan in interface KeyBinaryCommands
    • scan

      public ScanResult<byte[]> scan(byte[] cursor, ScanParams params, byte[] type)
      Specified by:
      scan in interface KeyBinaryCommands
    • hscan

      public ScanResult<Map.Entry<byte[],byte[]>> hscan(byte[] key, byte[] cursor)
      Specified by:
      hscan in interface HashBinaryCommands
    • hscan

      public ScanResult<Map.Entry<byte[],byte[]>> hscan(byte[] key, byte[] cursor, ScanParams params)
      Specified by:
      hscan in interface HashBinaryCommands
    • sscan

      public ScanResult<byte[]> sscan(byte[] key, byte[] cursor)
      Specified by:
      sscan in interface SetBinaryCommands
    • sscan

      public ScanResult<byte[]> sscan(byte[] key, byte[] cursor, ScanParams params)
      Specified by:
      sscan in interface SetBinaryCommands
    • zscan

      public ScanResult<Tuple> zscan(byte[] key, byte[] cursor)
      Specified by:
      zscan in interface SortedSetBinaryCommands
    • zscan

      public ScanResult<Tuple> zscan(byte[] key, byte[] cursor, ScanParams params)
      Specified by:
      zscan in interface SortedSetBinaryCommands
    • geoadd

      public long geoadd(byte[] key, double longitude, double latitude, byte[] member)
      Specified by:
      geoadd in interface GeoBinaryCommands
    • geoadd

      public long geoadd(byte[] key, Map<byte[],GeoCoordinate> memberCoordinateMap)
      Specified by:
      geoadd in interface GeoBinaryCommands
    • geoadd

      public long geoadd(byte[] key, GeoAddParams params, Map<byte[],GeoCoordinate> memberCoordinateMap)
      Specified by:
      geoadd in interface GeoBinaryCommands
    • geodist

      public Double geodist(byte[] key, byte[] member1, byte[] member2)
      Specified by:
      geodist in interface GeoBinaryCommands
    • geodist

      public Double geodist(byte[] key, byte[] member1, byte[] member2, GeoUnit unit)
      Specified by:
      geodist in interface GeoBinaryCommands
    • geohash

      public List<byte[]> geohash(byte[] key, byte[]... members)
      Specified by:
      geohash in interface GeoBinaryCommands
    • geopos

      public List<GeoCoordinate> geopos(byte[] key, byte[]... members)
      Specified by:
      geopos in interface GeoBinaryCommands
    • georadius

      public List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude, double radius, GeoUnit unit)
      Specified by:
      georadius in interface GeoBinaryCommands
    • georadiusReadonly

      public List<GeoRadiusResponse> georadiusReadonly(byte[] key, double longitude, double latitude, double radius, GeoUnit unit)
      Specified by:
      georadiusReadonly in interface GeoBinaryCommands
    • georadius

      public List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param)
      Specified by:
      georadius in interface GeoBinaryCommands
    • georadiusStore

      public long georadiusStore(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam)
      Specified by:
      georadiusStore in interface GeoBinaryCommands
    • georadiusReadonly

      public List<GeoRadiusResponse> georadiusReadonly(byte[] key, double longitude, double latitude, double radius, GeoUnit unit, GeoRadiusParam param)
      Specified by:
      georadiusReadonly in interface GeoBinaryCommands
    • georadiusByMember

      public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit)
      Specified by:
      georadiusByMember in interface GeoBinaryCommands
    • georadiusByMemberReadonly

      public List<GeoRadiusResponse> georadiusByMemberReadonly(byte[] key, byte[] member, double radius, GeoUnit unit)
      Specified by:
      georadiusByMemberReadonly in interface GeoBinaryCommands
    • georadiusByMember

      public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param)
      Specified by:
      georadiusByMember in interface GeoBinaryCommands
    • georadiusByMemberStore

      public long georadiusByMemberStore(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param, GeoRadiusStoreParam storeParam)
      Specified by:
      georadiusByMemberStore in interface GeoBinaryCommands
    • geosearch

      public List<GeoRadiusResponse> geosearch(byte[] key, byte[] member, double radius, GeoUnit unit)
      Specified by:
      geosearch in interface GeoBinaryCommands
    • geosearch

      public List<GeoRadiusResponse> geosearch(byte[] key, GeoCoordinate coord, double radius, GeoUnit unit)
      Specified by:
      geosearch in interface GeoBinaryCommands
    • geosearch

      public List<GeoRadiusResponse> geosearch(byte[] key, byte[] member, double width, double height, GeoUnit unit)
      Specified by:
      geosearch in interface GeoBinaryCommands
    • geosearch

      public List<GeoRadiusResponse> geosearch(byte[] key, GeoCoordinate coord, double width, double height, GeoUnit unit)
      Specified by:
      geosearch in interface GeoBinaryCommands
    • geosearch

      public List<GeoRadiusResponse> geosearch(byte[] key, GeoSearchParam params)
      Specified by:
      geosearch in interface GeoBinaryCommands
    • geosearchStore

      public long geosearchStore(byte[] dest, byte[] src, byte[] member, double radius, GeoUnit unit)
      Specified by:
      geosearchStore in interface GeoBinaryCommands
    • geosearchStore

      public long geosearchStore(byte[] dest, byte[] src, GeoCoordinate coord, double radius, GeoUnit unit)
      Specified by:
      geosearchStore in interface GeoBinaryCommands
    • geosearchStore

      public long geosearchStore(byte[] dest, byte[] src, byte[] member, double width, double height, GeoUnit unit)
      Specified by:
      geosearchStore in interface GeoBinaryCommands
    • geosearchStore

      public long geosearchStore(byte[] dest, byte[] src, GeoCoordinate coord, double width, double height, GeoUnit unit)
      Specified by:
      geosearchStore in interface GeoBinaryCommands
    • geosearchStore

      public long geosearchStore(byte[] dest, byte[] src, GeoSearchParam params)
      Specified by:
      geosearchStore in interface GeoBinaryCommands
    • geosearchStoreStoreDist

      public long geosearchStoreStoreDist(byte[] dest, byte[] src, GeoSearchParam params)
      Specified by:
      geosearchStoreStoreDist in interface GeoBinaryCommands
    • georadiusByMemberReadonly

      public List<GeoRadiusResponse> georadiusByMemberReadonly(byte[] key, byte[] member, double radius, GeoUnit unit, GeoRadiusParam param)
      Specified by:
      georadiusByMemberReadonly in interface GeoBinaryCommands
    • bitfield

      public List<Long> bitfield(byte[] key, byte[]... arguments)
      Specified by:
      bitfield in interface BitBinaryCommands
    • bitfieldReadonly

      public List<Long> bitfieldReadonly(byte[] key, byte[]... arguments)
      Specified by:
      bitfieldReadonly in interface BitBinaryCommands
    • hstrlen

      public long hstrlen(byte[] key, byte[] field)
      Specified by:
      hstrlen in interface HashBinaryCommands
    • xread

      public List<Object> xread(XReadParams xReadParams, Map.Entry<byte[],byte[]>... streams)
      Specified by:
      xread in interface StreamBinaryCommands
    • xreadGroup

      public List<Object> xreadGroup(byte[] groupName, byte[] consumer, XReadGroupParams xReadGroupParams, Map.Entry<byte[],byte[]>... streams)
      Specified by:
      xreadGroup in interface StreamBinaryCommands
    • xadd

      public byte[] xadd(byte[] key, XAddParams params, Map<byte[],byte[]> hash)
      Specified by:
      xadd in interface StreamBinaryCommands
    • xlen

      public long xlen(byte[] key)
      Specified by:
      xlen in interface StreamBinaryCommands
    • xrange

      public List<Object> xrange(byte[] key, byte[] start, byte[] end)
      Specified by:
      xrange in interface StreamBinaryCommands
    • xrange

      public List<Object> xrange(byte[] key, byte[] start, byte[] end, int count)
      Specified by:
      xrange in interface StreamBinaryCommands
    • xrevrange

      public List<Object> xrevrange(byte[] key, byte[] end, byte[] start)
      Specified by:
      xrevrange in interface StreamBinaryCommands
    • xrevrange

      public List<Object> xrevrange(byte[] key, byte[] end, byte[] start, int count)
      Specified by:
      xrevrange in interface StreamBinaryCommands
    • xack

      public long xack(byte[] key, byte[] group, byte[]... ids)
      Specified by:
      xack in interface StreamBinaryCommands
    • xgroupCreate

      public String xgroupCreate(byte[] key, byte[] consumer, byte[] id, boolean makeStream)
      Specified by:
      xgroupCreate in interface StreamBinaryCommands
    • xgroupSetID

      public String xgroupSetID(byte[] key, byte[] consumer, byte[] id)
      Specified by:
      xgroupSetID in interface StreamBinaryCommands
    • xgroupDestroy

      public long xgroupDestroy(byte[] key, byte[] consumer)
      Specified by:
      xgroupDestroy in interface StreamBinaryCommands
    • xgroupCreateConsumer

      public boolean xgroupCreateConsumer(byte[] key, byte[] groupName, byte[] consumerName)
      Specified by:
      xgroupCreateConsumer in interface StreamBinaryCommands
    • xgroupDelConsumer

      public long xgroupDelConsumer(byte[] key, byte[] groupName, byte[] consumerName)
      Specified by:
      xgroupDelConsumer in interface StreamBinaryCommands
    • xdel

      public long xdel(byte[] key, byte[]... ids)
      Specified by:
      xdel in interface StreamBinaryCommands
    • xtrim

      public long xtrim(byte[] key, long maxLen, boolean approximateLength)
      Specified by:
      xtrim in interface StreamBinaryCommands
    • xtrim

      public long xtrim(byte[] key, XTrimParams params)
      Specified by:
      xtrim in interface StreamBinaryCommands
    • xpending

      @Deprecated public List<Object> xpending(byte[] key, byte[] groupName, byte[] start, byte[] end, int count, byte[] consumerName)
      Specified by:
      xpending in interface StreamBinaryCommands
    • xpending

      public Object xpending(byte[] key, byte[] groupName)
      Specified by:
      xpending in interface StreamBinaryCommands
    • xpending

      public List<Object> xpending(byte[] key, byte[] groupName, XPendingParams params)
      Specified by:
      xpending in interface StreamBinaryCommands
    • xclaim

      public List<byte[]> xclaim(byte[] key, byte[] group, byte[] consumerName, long minIdleTime, XClaimParams params, byte[]... ids)
      Specified by:
      xclaim in interface StreamBinaryCommands
    • xclaimJustId

      public List<byte[]> xclaimJustId(byte[] key, byte[] group, byte[] consumerName, long minIdleTime, XClaimParams params, byte[]... ids)
      Specified by:
      xclaimJustId in interface StreamBinaryCommands
    • xautoclaim

      public List<Object> xautoclaim(byte[] key, byte[] groupName, byte[] consumerName, long minIdleTime, byte[] start, XAutoClaimParams params)
      Specified by:
      xautoclaim in interface StreamBinaryCommands
    • xautoclaimJustId

      public List<Object> xautoclaimJustId(byte[] key, byte[] groupName, byte[] consumerName, long minIdleTime, byte[] start, XAutoClaimParams params)
      Specified by:
      xautoclaimJustId in interface StreamBinaryCommands
    • xinfoStream

      public Object xinfoStream(byte[] key)
      Specified by:
      xinfoStream in interface StreamBinaryCommands
    • xinfoStreamFull

      public Object xinfoStreamFull(byte[] key)
      Description copied from interface: StreamBinaryCommands
      Introspection command used in order to retrieve all information about the stream
      Specified by:
      xinfoStreamFull in interface StreamBinaryCommands
      Parameters:
      key - Stream name
    • xinfoStreamFull

      public Object xinfoStreamFull(byte[] key, int count)
      Description copied from interface: StreamBinaryCommands
      Introspection command used in order to retrieve all information about the stream
      Specified by:
      xinfoStreamFull in interface StreamBinaryCommands
      Parameters:
      key - Stream name
      count - stream info count
    • xinfoGroup

      @Deprecated public List<Object> xinfoGroup(byte[] key)
      Deprecated.
      Specified by:
      xinfoGroup in interface StreamBinaryCommands
    • xinfoGroups

      public List<Object> xinfoGroups(byte[] key)
      Specified by:
      xinfoGroups in interface StreamBinaryCommands
    • xinfoConsumers

      public List<Object> xinfoConsumers(byte[] key, byte[] group)
      Specified by:
      xinfoConsumers in interface StreamBinaryCommands
    • sendCommand

      public Object sendCommand(ProtocolCommand cmd, byte[]... args)
    • sendBlockingCommand

      public Object sendBlockingCommand(ProtocolCommand cmd, byte[]... args)
    • sendCommand

      public Object sendCommand(ProtocolCommand cmd)
    • copy

      public boolean copy(String srcKey, String dstKey, int db, boolean replace)
      COPY source destination [DB destination-db] [REPLACE]
      Specified by:
      copy in interface DatabaseCommands
      Parameters:
      srcKey - the source key.
      dstKey - the destination key.
      db -
      replace -
    • copy

      public boolean copy(String srcKey, String dstKey, boolean replace)
      COPY source destination [REPLACE]
      Specified by:
      copy in interface KeyCommands
      Parameters:
      srcKey - the source key.
      dstKey - the destination key.
      replace -
      Returns:
      true if source was copied, false otherwise
    • ping

      public String ping(String message)
      Works same as ping() but returns argument message instead of PONG.
      Specified by:
      ping in interface ServerCommands
      Parameters:
      message -
      Returns:
      message
    • set

      public String set(String key, String value)
      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:
      set in interface StringCommands
      Parameters:
      key -
      value -
      Returns:
      OK
    • set

      public String set(String key, String value, SetParams params)
      Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1 GB).
      Specified by:
      set in interface StringCommands
      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 OK if SET was executed correctly, or null if the SET operation was not performed because the user specified the NX or XX option but the condition was not met.
    • get

      public String get(String 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:
      get in interface StringCommands
      Parameters:
      key -
      Returns:
      Bulk reply
    • setGet

      public String setGet(String key, String value, SetParams params)
      Description copied from interface: StringCommands
      WARNING: SetParams.get() MUST NOT be used with this method.
      Specified by:
      setGet in interface StringCommands
    • getDel

      public String getDel(String 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:
      getDel in interface StringCommands
      Parameters:
      key -
      Returns:
      The value of key
    • getEx

      public String getEx(String key, GetExParams params)
      Description copied from interface: StringCommands
      GetEx Command Get the value of key and optionally set its expiration. GETEX is similar to GET, 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:
      getEx in interface StringCommands
      Parameters:
      key -
      params - GetExParams
      Returns:
      The value stored in key
    • exists

      public long exists(String... keys)
      Test if the specified keys exist. The command returns the number of keys exist. Time complexity: O(N)
      Specified by:
      exists in interface KeyCommands
      Parameters:
      keys -
      Returns:
      The number of keys that exist from those specified as keys
    • exists

      public boolean exists(String 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:
      exists in interface KeyCommands
      Parameters:
      key -
      Returns:
      true if the key exists, otherwise false
    • del

      public long del(String... 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:
      del in interface KeyCommands
      Parameters:
      keys -
      Returns:
      An integer greater than 0 if one or more keys were removed, 0 if none of the specified keys existed
    • del

      public long del(String key)
      Description copied from interface: KeyCommands
      Del Command Remove the specified key. If a given key does not exist, no operation is performed.

      Time complexity: O(1)

      Specified by:
      del in interface KeyCommands
      Parameters:
      key -
      Returns:
      1 if the key was removed, 0 if the key does not exist
    • unlink

      public long unlink(String... 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:
      unlink in interface KeyCommands
      Parameters:
      keys -
      Returns:
      The number of keys that were unlinked
      See Also:
    • unlink

      public long unlink(String key)
      Description copied from interface: KeyCommands
      Unlink Command This command is very similar to DEL: 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:
      unlink in interface KeyCommands
      Parameters:
      key -
      Returns:
      The number of keys that were unlinked
    • type

      public String type(String key)
      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:
      type in interface KeyCommands
      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

      public Set<String> keys(String pattern)
      Description copied from interface: KeyCommands
      Keys 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:
      keys in interface KeyCommands
      Parameters:
      pattern -
      Returns:
      List of keys matching the pattern.
    • randomKey

      public String randomKey()
      Return a randomly selected key from the currently selected DB.

      Time complexity: O(1)

      Specified by:
      randomKey in interface KeyCommands
      Returns:
      Randomly selected key or an empty string if the database is empty
    • rename

      public String rename(String oldkey, String newkey)
      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:
      rename in interface KeyCommands
      Parameters:
      oldkey -
      newkey -
      Returns:
      OK
    • renamenx

      public long renamenx(String oldkey, String newkey)
      Rename oldkey into newkey but fails if the destination key newkey already exists.

      Time complexity: O(1)

      Specified by:
      renamenx in interface KeyCommands
      Parameters:
      oldkey -
      newkey -
      Returns:
      1 if the key was renamed, 0 if the target key already exist
    • expire

      public long expire(String 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 PERSIST command.

      Time complexity: O(1)

      Specified by:
      expire in interface KeyCommands
      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

      public long expire(String key, long seconds, ExpiryOption expiryOption)
      Similar to EXPIRE but with optional expiry setting.
      Specified by:
      expire in interface KeyCommands
      Parameters:
      key -
      seconds - time to expire
      expiryOption - 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

      public long pexpire(String key, long milliseconds)
      Description copied from interface: KeyCommands
      PExpire Command This command works exactly like EXPIRE but the time to live of the key is specified in milliseconds instead of seconds.

      Time complexity: O(1)

      Specified by:
      pexpire in interface KeyCommands
      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

      public long pexpire(String key, long milliseconds, ExpiryOption expiryOption)
      Description copied from interface: KeyCommands
      Similar to EXPIRE but with optional expiry setting.
      Specified by:
      pexpire in interface KeyCommands
      Parameters:
      key -
      milliseconds - time to expire
      expiryOption - 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

      public long expireTime(String key)
      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:
      expireTime in interface KeyCommands
      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

      public long pexpireTime(String key)
      Similar to EXPIRETIME but returns the absolute Unix expiration timestamp in milliseconds instead of seconds.

      Time complexity: O(1)

      Specified by:
      pexpireTime in interface KeyCommands
      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

      public long expireAt(String key, long unixTime)
      EXPIREAT works exactly like EXPIRE but instead to get the number of seconds representing the Time To Live of the key as a second argument (that is a relative way of specifying the TTL), it takes an absolute one in the form of a UNIX timestamp (Number of seconds elapsed since 1 Gen 1970).

      EXPIREAT was introduced in order to implement the Append Only File persistence mode so that EXPIRE commands are automatically translated into EXPIREAT commands for the append only file. Of course EXPIREAT can also used by programmers that need a way to simply specify that a given key should expire at a given time in the future.

      Since Redis 2.1.3 you can update the value of the timeout of a key already having an expire set. It is also possible to undo the expire at all turning the key into a normal key using the PERSIST command.

      Time complexity: O(1)

      Specified by:
      expireAt in interface KeyCommands
      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

      public long expireAt(String key, long unixTime, ExpiryOption expiryOption)
      Similar to EXPIREAT but with ExpiryOption.
      Specified by:
      expireAt in interface KeyCommands
      Parameters:
      key -
      unixTime - time to expire
      expiryOption - 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

      public long pexpireAt(String key, long millisecondsTimestamp)
      This command works exactly like EXPIREAT but Unix time at which the key will expire is specified in milliseconds instead of seconds.

      Time complexity: O(1)

      Specified by:
      pexpireAt in interface KeyCommands
      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

      public long pexpireAt(String key, long millisecondsTimestamp, ExpiryOption expiryOption)
      ExpireAt Command Similar to PEXPIREAT but with ExpiryOption.
      Specified by:
      pexpireAt in interface KeyCommands
      Parameters:
      key -
      millisecondsTimestamp - time to expire
      expiryOption - 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

      public long ttl(String key)
      The TTL command returns the remaining time to live in seconds of a key that has an EXPIRE set. This introspection capability allows a Redis connection to check how many seconds a given key will continue to be part of the dataset.
      Specified by:
      ttl in interface KeyCommands
      Parameters:
      key -
      Returns:
      TTL in seconds, or a negative value in order to signal an error
    • touch

      public long touch(String... 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:
      touch in interface KeyCommands
      Parameters:
      keys -
      Returns:
      The number of keys that were touched.
    • touch

      public long touch(String key)
      Description copied from interface: KeyCommands
      Touch 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:
      touch in interface KeyCommands
      Parameters:
      key -
      Returns:
      The number of keys that were touched
    • move

      public long move(String 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:
      move in interface DatabaseCommands
      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

      public String getSet(String key, String 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:
      getSet in interface StringCommands
      Parameters:
      key -
      value -
      Returns:
      Bulk reply
    • mget

      public List<String> mget(String... keys)
      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:
      mget in interface StringCommands
      Parameters:
      keys -
      Returns:
      Multi bulk reply
    • setnx

      public long setnx(String key, String value)
      SETNX works exactly like SET with the only difference that if the key already exists no operation is performed. SETNX actually means "SET if Not eXists".

      Time complexity: O(1)

      Specified by:
      setnx in interface StringCommands
      Parameters:
      key -
      value -
      Returns:
      1 if the key was set, 0 if the key was not set
    • setex

      public String setex(String key, long seconds, String value)
      The command is exactly equivalent to the following group of commands: SET + EXPIRE. The operation is atomic.

      Time complexity: O(1)

      Specified by:
      setex in interface StringCommands
      Parameters:
      key -
      seconds -
      value -
      Returns:
      OK
    • mset

      public String mset(String... keysvalues)
      Set the the respective keys to the respective values. MSET will replace old values with new values, while MSETNX will not perform any operation at all even if just a single key already exists.

      Because of this semantic MSETNX can be used in order to set different keys representing different fields of an unique logic object in a way that ensures that either all the fields or none at all are set.

      Both MSET and MSETNX are atomic operations. This means that for instance if the keys A and B are modified, another connection talking to Redis can either see the changes to both A and B at once, or no modification at all.

      Specified by:
      mset in interface StringCommands
      Parameters:
      keysvalues -
      Returns:
      OK
      See Also:
    • msetnx

      public long msetnx(String... keysvalues)
      Set the the respective keys to the respective values. MSET will replace old values with new values, while MSETNX will not perform any operation at all even if just a single key already exists.

      Because of this semantic MSETNX can be used in order to set different keys representing different fields of an unique logic object in a way that ensures that either all the fields or none at all are set.

      Both MSET and MSETNX are atomic operations. This means that for instance if the keys A and B are modified, another connection talking to Redis can either see the changes to both A and B at once, or no modification at all.

      Specified by:
      msetnx in interface StringCommands
      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(String key, long decrement)
      IDECRBY work just like INCR but instead to decrement by 1 the decrement is integer.

      INCR commands are limited to 64 bit signed integers.

      Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.

      Time complexity: O(1)

      Specified by:
      decrBy in interface StringCommands
      Parameters:
      key -
      decrement -
      Returns:
      The value of key after the decrement
      See Also:
    • decr

      public long decr(String 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.

      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:
      decr in interface StringCommands
      Parameters:
      key -
      Returns:
      The value of key after the decrement
      See Also:
    • incrBy

      public long incrBy(String key, long increment)
      INCRBY work just like INCR but instead to increment by 1 the increment is integer.

      INCR commands are limited to 64 bit signed integers.

      Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.

      Time complexity: O(1)

      Specified by:
      incrBy in interface StringCommands
      Parameters:
      key -
      increment -
      Returns:
      The value of key after the increment
      See Also:
    • incrByFloat

      public double incrByFloat(String key, double increment)
      INCRBYFLOAT

      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:
      incrByFloat in interface StringCommands
      Parameters:
      key -
      increment -
      Returns:
      The value of key after the increment
    • incr

      public long incr(String 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:
      incr in interface StringCommands
      Parameters:
      key -
      Returns:
      The value of key after the increment
      See Also:
    • append

      public long append(String key, String value)
      If the key already exists and is a string, this command appends the provided value at the end of the string. 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:
      append in interface StringCommands
      Parameters:
      key -
      value -
      Returns:
      The total length of the string after the append operation.
    • substr

      public String substr(String 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:
      substr in interface StringCommands
      Parameters:
      key -
      start -
      end -
      Returns:
      The substring
    • hset

      public long hset(String key, String field, String 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:
      hset in interface HashCommands
      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

      public long hset(String key, Map<String,String> hash)
      Specified by:
      hset in interface HashCommands
    • hget

      public String hget(String key, String 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:
      hget in interface HashCommands
      Parameters:
      key -
      field -
      Returns:
      Bulk reply
    • hsetnx

      public long hsetnx(String key, String field, String value)
      Set the specified hash field to the specified value if the field not exists. Time complexity: O(1)
      Specified by:
      hsetnx in interface HashCommands
      Parameters:
      key -
      field -
      value -
      Returns:
      If the field already exists, 0 is returned, otherwise if a new field is created 1 is returned.
    • hmset

      public String hmset(String key, Map<String,String> hash)
      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:
      hmset in interface HashCommands
      Parameters:
      key -
      hash -
      Returns:
      Return OK or Exception if hash is empty
    • hmget

      public List<String> hmget(String key, String... fields)
      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:
      hmget in interface HashCommands
      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(String key, String 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:
      hincrBy in interface HashCommands
      Parameters:
      key -
      field -
      value -
      Returns:
      The value of key after the increment
    • hincrByFloat

      public double hincrByFloat(String key, String field, double value)
      Increment the number stored at field in the hash at key by a double precision floating point value. 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:
      hincrByFloat in interface HashCommands
      Parameters:
      key -
      field -
      value -
      Returns:
      The new value at field after the increment operation
    • hexists

      public boolean hexists(String key, String field)
      Test for existence of a specified field in a hash. Time complexity: O(1)
      Specified by:
      hexists in interface HashCommands
      Parameters:
      key -
      field -
      Returns:
      true if the hash stored at key contains the specified field, false if the key is not found or the field is not present.
    • hdel

      public long hdel(String key, String... fields)
      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:
      hdel in interface HashCommands
      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

      public long hlen(String key)
      Return the number of items in a hash.

      Time complexity: O(1)

      Specified by:
      hlen in interface HashCommands
      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

      public Set<String> hkeys(String key)
      Return all the fields in a hash.

      Time complexity: O(N), where N is the total number of entries

      Specified by:
      hkeys in interface HashCommands
      Parameters:
      key -
      Returns:
      All the fields names contained into a hash.
    • hvals

      public List<String> hvals(String key)
      Return all the values in a hash.

      Time complexity: O(N), where N is the total number of entries

      Specified by:
      hvals in interface HashCommands
      Parameters:
      key -
      Returns:
      All the fields values contained into a hash.
    • hgetAll

      public Map<String,String> hgetAll(String key)
      Return all the fields and associated values in a hash.

      Time complexity: O(N), where N is the total number of entries

      Specified by:
      hgetAll in interface HashCommands
      Parameters:
      key -
      Returns:
      All the fields and values contained into a hash.
    • hrandfield

      public String hrandfield(String key)
      Get one random field from a hash.

      Time complexity: O(N), where N is the number of fields returned

      Specified by:
      hrandfield in interface HashCommands
      Parameters:
      key -
      Returns:
      one random field from a hash.
    • hrandfield

      public List<String> hrandfield(String key, long count)
      Get multiple random fields from a hash.

      Time complexity: O(N), where N is the number of fields returned

      Specified by:
      hrandfield in interface HashCommands
      Parameters:
      key -
      count -
      Returns:
      multiple random fields from a hash.
    • hrandfieldWithValues

      public Map<String,String> hrandfieldWithValues(String key, long count)
      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:
      hrandfieldWithValues in interface HashCommands
      Parameters:
      key -
      count -
      Returns:
      one or multiple random fields with values from a hash.
    • rpush

      public long rpush(String key, String... 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:
      rpush in interface ListCommands
      Parameters:
      key -
      strings -
      Returns:
      The number of elements inside the list after the push operation
    • lpush

      public long lpush(String key, String... 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:
      lpush in interface ListCommands
      Parameters:
      key -
      strings -
      Returns:
      The number of elements inside the list after the push operation
    • llen

      public long llen(String 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:
      llen in interface ListCommands
      Parameters:
      key -
      Returns:
      The length of the list
    • lrange

      public List<String> lrange(String key, long start, long stop)
      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:
      lrange in interface ListCommands
      Parameters:
      key -
      start -
      stop -
      Returns:
      A list of elements in the specified range
    • ltrim

      public String ltrim(String key, long start, long stop)
      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:
      ltrim in interface ListCommands
      Parameters:
      key -
      start -
      stop -
      Returns:
      OK
    • lindex

      public String lindex(String 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:
      lindex in interface ListCommands
      Parameters:
      key -
      index -
      Returns:
      The requested element
    • lset

      public String lset(String key, long index, String value)
      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:
      lset in interface ListCommands
      Parameters:
      key -
      index -
      value -
      Returns:
      OK
      See Also:
    • lrem

      public long lrem(String key, long count, String 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:
      lrem in interface ListCommands
      Parameters:
      key -
      count -
      value -
      Returns:
      The number of removed elements if the operation succeeded
    • lpop

      public String lpop(String 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:
      lpop in interface ListCommands
      Parameters:
      key -
      Returns:
      Bulk reply
      See Also:
    • lpop

      public List<String> lpop(String key, int count)
      Description copied from interface: ListCommands
      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".
      Specified by:
      lpop in interface ListCommands
      Parameters:
      key -
      count -
      Returns:
      A list of popped elements, or 'nil' when key does not exist
    • lpos

      public Long lpos(String key, String element)
      Description copied from interface: ListCommands
      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:
      lpos in interface ListCommands
      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

      public Long lpos(String key, String element, LPosParams params)
      Description copied from interface: ListCommands
      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:
      lpos in interface ListCommands
      Parameters:
      key -
      element -
      params - LPosParams
      Returns:
      The integer representing the matching element, or 'nil' if there is no match
    • lpos

      public List<Long> lpos(String key, String element, LPosParams params, long count)
      Description copied from interface: ListCommands
      Returns 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:
      lpos in interface ListCommands
      Parameters:
      key -
      element -
      params - LPosParams
      count -
      Returns:
      A list containing position of the matching elements inside the list
    • rpop

      public String rpop(String 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" 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:
      rpop in interface ListCommands
      Parameters:
      key -
      Returns:
      Bulk reply
      See Also:
    • rpop

      public List<String> rpop(String key, int count)
      Description copied from interface: ListCommands
      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".
      Specified by:
      rpop in interface ListCommands
      Parameters:
      key -
      count - return up to count elements
      Returns:
      A list of count popped elements, or 'nil' when key does not exist.
    • rpoplpush

      public String rpoplpush(String srckey, String dstkey)
      Atomically return and remove the last (tail) element of the srckey list, and push the element as the first (head) element of the dstkey list. 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:
      rpoplpush in interface ListCommands
      Parameters:
      srckey -
      dstkey -
      Returns:
      Bulk reply
    • sadd

      public long sadd(String key, String... 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:
      sadd in interface SetCommands
      Parameters:
      key -
      members -
      Returns:
      1 if the new element was added, 0 if the element was already a member of the set
    • smembers

      public Set<String> smembers(String key)
      Return all the members (elements) of the set value stored at key. This is just syntax glue for SINTER.

      Time complexity O(N)

      Specified by:
      smembers in interface SetCommands
      Parameters:
      key -
      Returns:
      Multi bulk reply
    • srem

      public long srem(String key, String... 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:
      srem in interface SetCommands
      Parameters:
      key -
      members -
      Returns:
      1 if the new element was removed, 0 if the new element was not a member of the set
    • spop

      public String spop(String 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(String) command does a similar work but the returned element is not removed from the Set.

      Time complexity O(1)

      Specified by:
      spop in interface SetCommands
      Parameters:
      key -
      Returns:
      Bulk reply
    • spop

      public Set<String> spop(String key, long count)
      Description copied from interface: SetCommands
      By default, the command SetCommands.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:
      spop in interface SetCommands
      Parameters:
      key -
      count -
      Returns:
      The removed members
    • smove

      public long smove(String srckey, String dstkey, String 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:
      smove in interface SetCommands
      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

      public long scard(String key)
      Return the set cardinality (number of elements). If the key does not exist 0 is returned, like for empty sets.
      Specified by:
      scard in interface SetCommands
      Parameters:
      key -
      Returns:
      The cardinality (number of elements) of the set as an integer
    • sismember

      public boolean sismember(String key, String member)
      Return true if member is a member of the set stored at key, otherwise false is returned.

      Time complexity O(1)

      Specified by:
      sismember in interface SetCommands
      Parameters:
      key -
      member -
      Returns:
      true if the element is a member of the set, false otherwise
    • smismember

      public List<Boolean> smismember(String key, String... members)
      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:
      smismember in interface SetCommands
      Parameters:
      key -
      members -
      Returns:
      List representing the membership of the given elements, in the same order as they are requested
    • sinter

      public Set<String> sinter(String... keys)
      Return the members of a set resulting from the intersection of all the sets hold at the specified keys. Like in LRANGE the result is sent to the connection as a multi-bulk reply (see the protocol specification for more information). If just a single key is specified, then this command produces the same result as SMEMBERS. Actually SMEMBERS is just syntax sugar for SINTER.

      Non existing keys are considered like empty sets, so if one of the keys is missing an empty set is returned (since the intersection with an empty set always is an empty set).

      Time complexity O(N*M) worst case where N is the cardinality of the smallest set and M the number of sets

      Specified by:
      sinter in interface SetCommands
      Parameters:
      keys -
      Returns:
      A set with members of the resulting set
    • sinterstore

      public long sinterstore(String dstkey, String... keys)
      This command works exactly like SINTER but instead of being returned the resulting set is stored as dstkey.

      Time complexity O(N*M) worst case where N is the cardinality of the smallest set and M the number of sets

      Specified by:
      sinterstore in interface SetCommands
      Parameters:
      dstkey -
      keys -
      Returns:
      The number of elements in the resulting set
    • sintercard

      public long sintercard(String... keys)
      This command works exactly like SINTER but 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:
      sintercard in interface SetCommands
      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, String... keys)
      This command works exactly like SINTER but 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:
      sintercard in interface SetCommands
      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

      public Set<String> sunion(String... keys)
      Return the members of a set resulting from the union of all the sets hold at the specified keys. Like in LRANGE the result is sent to the connection as a multi-bulk reply (see the protocol specification for more information). If just a single key is specified, then this command produces the same result as SMEMBERS.

      Non existing keys are considered like empty sets.

      Time complexity O(N) where N is the total number of elements in all the provided sets

      Specified by:
      sunion in interface SetCommands
      Parameters:
      keys -
      Returns:
      A set with members of the resulting set
    • sunionstore

      public long sunionstore(String dstkey, String... keys)
      This command works exactly like SUNION but instead of being returned the resulting set is stored as dstkey. Any existing value in dstkey will be over-written.

      Time complexity O(N) where N is the total number of elements in all the provided sets

      Specified by:
      sunionstore in interface SetCommands
      Parameters:
      dstkey -
      keys -
      Returns:
      The number of elements in the resulting set
    • sdiff

      public Set<String> sdiff(String... keys)
      Return the difference between the Set stored at key1 and all the Sets key2, ..., keyN

      Example:

       key1 = [x, a, b, c]
       key2 = [c]
       key3 = [a, d]
       SDIFF key1,key2,key3 => [x, b]
       
      Non existing keys are considered like empty sets.

      Time complexity:

      O(N) with N being the total number of elements of all the sets

      Specified by:
      sdiff in interface SetCommands
      Parameters:
      keys -
      Returns:
      A set with members of the resulting set
    • sdiffstore

      public long sdiffstore(String dstkey, String... keys)
      This command works exactly like SDIFF but instead of being returned the resulting set is stored in dstkey.
      Specified by:
      sdiffstore in interface SetCommands
      Parameters:
      dstkey -
      keys -
      Returns:
      The number of elements in the resulting set
    • srandmember

      public String srandmember(String 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:
      srandmember in interface SetCommands
      Parameters:
      key -
      Returns:
      The randomly selected element
    • srandmember

      public List<String> srandmember(String key, int count)
      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:
      srandmember in interface SetCommands
      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

      public long zadd(String key, double score, String 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:
      zadd in interface SortedSetCommands
      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

      public long zadd(String key, double score, String member, ZAddParams params)
      Description copied from interface: SortedSetCommands
      Similar to ZADD but can be used with optional params.
      Specified by:
      zadd in interface SortedSetCommands
      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

      public long zadd(String key, Map<String,Double> scoreMembers)
      Description copied from interface: SortedSetCommands
      Similar to ZADD but for multiple members.
      Specified by:
      zadd in interface SortedSetCommands
      Parameters:
      key -
      scoreMembers -
      Returns:
      The number of elements added to the sorted set (excluding score updates).
      See Also:
    • zadd

      public long zadd(String key, Map<String,Double> scoreMembers, ZAddParams params)
      Description copied from interface: SortedSetCommands
      Similar to ZADD but can be used with optional params, and fits for multiple members.
      Specified by:
      zadd in interface SortedSetCommands
      Parameters:
      key -
      scoreMembers -
      params - ZAddParams
      Returns:
      The number of elements added to the sorted set (excluding score updates).
      See Also:
    • zaddIncr

      public Double zaddIncr(String key, double score, String member, ZAddParams params)
      Description copied from interface: SortedSetCommands
      Increments 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:
      zaddIncr in interface SortedSetCommands
      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

      public Set<String> zdiff(String... keys)
      Description copied from interface: SortedSetCommands
      Compute 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:
      zdiff in interface SortedSetCommands
      Parameters:
      keys - group of sets
      Returns:
      The result of the difference
    • zdiffWithScores

      public Set<Tuple> zdiffWithScores(String... keys)
      Description copied from interface: SortedSetCommands
      Compute the difference between all the sets in the given keys. Return the result with scores.
      Specified by:
      zdiffWithScores in interface SortedSetCommands
      Parameters:
      keys - group of sets
      Returns:
      The result of the difference with their scores
    • zdiffStore

      public long zdiffStore(String dstkey, String... keys)
      Description copied from interface: SortedSetCommands
      Compute the difference between all the sets in the given keys. Store the result in dstkey.
      Specified by:
      zdiffStore in interface SortedSetCommands
      Parameters:
      dstkey -
      keys - group of sets
      Returns:
      The number of elements in the resulting sorted set at dstkey.
    • zrange

      public List<String> zrange(String key, long start, long stop)
      Description copied from interface: SortedSetCommands
      Returns 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:
      zrange in interface SortedSetCommands
      Parameters:
      key - the key to query
      start - the minimum index
      stop - the maximum index
      Returns:
      A List of Strings in the specified range
    • zrem

      public long zrem(String key, String... 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 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:
      zrem in interface SortedSetCommands
      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(String key, double increment, String member)
      If member already exists in the sorted set adds the increment to its score and updates the position of the element in the sorted set accordingly. 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:
      zincrby in interface SortedSetCommands
      Parameters:
      key -
      increment -
      member -
      Returns:
      The new score
    • zincrby

      public Double zincrby(String key, double increment, String member, ZIncrByParams params)
      Description copied from interface: SortedSetCommands
      Similar to ZINCRBY but can be used with optionals params.
      Specified by:
      zincrby in interface SortedSetCommands
      Parameters:
      key -
      increment -
      member -
      params - ZIncrByParams
      Returns:
      The new score for key
      See Also:
    • zrank

      public Long zrank(String key, String member)
      Return the rank (or index) of member in the sorted set at key, with scores being ordered from low to high.

      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:
      zrank in interface SortedSetCommands
      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

      public Long zrevrank(String key, String member)
      Return the rank (or index) of member in the sorted set at key, with scores being ordered from high to low.

      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:
      zrevrank in interface SortedSetCommands
      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

      public KeyValue<Long,Double> 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.
      Specified by:
      zrankWithScore in interface SortedSetCommands
      Parameters:
      key - the key
      member - the member
      Returns:
      the KeyValue contains rank and score.
    • zrevrankWithScore

      public KeyValue<Long,Double> 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.
      Specified by:
      zrevrankWithScore in interface SortedSetCommands
      Parameters:
      key - the key
      member - the member
      Returns:
      the KeyValue contains rank and score.
    • zrevrange

      public List<String> zrevrange(String key, long start, long stop)
      Description copied from interface: SortedSetCommands
      Returns 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:
      zrevrange in interface SortedSetCommands
      Parameters:
      key - the key to query
      start - the minimum index
      stop - the maximum index
      Returns:
      A List of Strings in the specified range
    • zrangeWithScores

      public List<Tuple> zrangeWithScores(String key, long start, long stop)
      Description copied from interface: SortedSetCommands
      Returns the specified range of elements in the sorted set stored at key with the scores.
      Specified by:
      zrangeWithScores in interface SortedSetCommands
      Parameters:
      key - the key to query
      start - the minimum index
      stop - the maximum index
      Returns:
      A List of Tuple in the specified range (elements names and their scores)
    • zrevrangeWithScores

      public List<Tuple> zrevrangeWithScores(String key, long start, long stop)
      Description copied from interface: SortedSetCommands
      Similar to ZREVRANGE but the reply will include the scores of the returned elements.
      Specified by:
      zrevrangeWithScores in interface SortedSetCommands
      Parameters:
      key - the key to query
      start - the minimum index
      stop - the maximum index
      Returns:
      A List of Tuple in the specified range (elements names and their scores)
      See Also:
    • zrange

      public List<String> zrange(String key, ZRangeParams zRangeParams)
      Description copied from interface: SortedSetCommands
      Similar to ZRANGE but can be used with additional params.
      Specified by:
      zrange in interface SortedSetCommands
      Parameters:
      key - the key to query
      zRangeParams - ZRangeParams
      Returns:
      A List of Strings in the specified range
      See Also:
    • zrangeWithScores

      public List<Tuple> zrangeWithScores(String key, ZRangeParams zRangeParams)
      Description copied from interface: SortedSetCommands
      Similar to ZRANGE but can be used with additional params.
      Specified by:
      zrangeWithScores in interface SortedSetCommands
      Parameters:
      key - the key to query
      zRangeParams - ZRangeParams
      Returns:
      A List of Tuple in the specified range (elements names and their scores)
      See Also:
    • zrangestore

      public long zrangestore(String dest, String src, ZRangeParams zRangeParams)
      Description copied from interface: SortedSetCommands
      Similar to ZRANGE but stores the result in dest.
      Specified by:
      zrangestore in interface SortedSetCommands
      Parameters:
      dest - the storing key
      src - the key to query
      zRangeParams - ZRangeParams
      Returns:
      The number of elements in the resulting sorted set
      See Also:
    • zrandmember

      public String zrandmember(String key)
      Description copied from interface: SortedSetCommands
      Return 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:
      zrandmember in interface SortedSetCommands
      Parameters:
      key -
      Returns:
      Random String from the set
    • zrandmember

      public List<String> zrandmember(String key, long count)
      Description copied from interface: SortedSetCommands
      Return 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:
      zrandmember in interface SortedSetCommands
      Parameters:
      key -
      count - choose up to count elements
      Returns:
      A list of distinct Strings from the set
    • zrandmemberWithScores

      public List<Tuple> zrandmemberWithScores(String key, long count)
      Description copied from interface: SortedSetCommands
      Similar to ZRANDMEMBER but the replay will include the scores with the result.
      Specified by:
      zrandmemberWithScores in interface SortedSetCommands
      Parameters:
      key -
      count - choose up to count elements
      Returns:
      A List of distinct Strings with their scores
      See Also:
    • zcard

      public long zcard(String 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:
      zcard in interface SortedSetCommands
      Parameters:
      key -
      Returns:
      The cardinality (number of elements) of the set as an integer
    • zscore

      public Double zscore(String key, String member)
      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:
      zscore in interface SortedSetCommands
      Parameters:
      key -
      member -
      Returns:
      The score
    • zmscore

      public List<Double> zmscore(String key, String... members)
      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:
      zmscore in interface SortedSetCommands
      Parameters:
      key -
      members -
      Returns:
      The scores
    • zpopmax

      public Tuple zpopmax(String key)
      Description copied from interface: SortedSetCommands
      Remove 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:
      zpopmax in interface SortedSetCommands
      Parameters:
      key -
      Returns:
      The popped element and the score
    • zpopmax

      public List<Tuple> zpopmax(String key, int count)
      Description copied from interface: SortedSetCommands
      Remove 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:
      zpopmax in interface SortedSetCommands
      Parameters:
      key -
      count - the number of elements to pop
      Returns:
      A List of popped elements and scores
    • zpopmin

      public Tuple zpopmin(String key)
      Description copied from interface: SortedSetCommands
      Remove 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:
      zpopmin in interface SortedSetCommands
      Parameters:
      key -
      Returns:
      The popped element and the score
    • zpopmin

      public List<Tuple> zpopmin(String key, int count)
      Description copied from interface: SortedSetCommands
      Remove 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:
      zpopmin in interface SortedSetCommands
      Parameters:
      key -
      count - the number of elements to pop
      Returns:
      A List of popped elements and scores
    • watch

      public String watch(String... keys)
    • sort

      public List<String> sort(String key)
      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:
      sort in interface KeyCommands
      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

      public List<String> sort(String key, SortingParams sortingParams)
      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:
      sort in interface KeyCommands
      Parameters:
      key -
      sortingParams -
      Returns:
      a list of sorted elements.
      See Also:
    • sort

      public long sort(String key, SortingParams sortingParams, String dstkey)
      Sort a Set or a List accordingly to the specified parameters and store the result at dstkey.
      Specified by:
      sort in interface KeyCommands
      Parameters:
      key -
      sortingParams -
      dstkey -
      Returns:
      The number of elements of the list at dstkey
      See Also:
    • sortReadonly

      public List<String> sortReadonly(String key, SortingParams sortingParams)
      Description copied from interface: KeyCommands
      Read-only variant of the SORT command. It is exactly like the original SORT but refuses the STORE option and can safely be used in read-only replicas.
      Specified by:
      sortReadonly in interface KeyCommands
      Parameters:
      key - the key to sort
      sortingParams - SortingParams
      Returns:
      list of sorted elements.
    • sort

      public long sort(String key, String 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:
      sort in interface KeyCommands
      Parameters:
      key -
      dstkey -
      Returns:
      The number of elements of the list at dstkey
      See Also:
    • lmove

      public String lmove(String srcKey, String dstKey, ListDirection from, ListDirection to)
      Description copied from interface: ListCommands
      Pop an element from a list, push it to another list and return it
      Specified by:
      lmove in interface ListCommands
      Parameters:
      srcKey -
      dstKey -
      from - can be LEFT or RIGHT
      to - 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: ListCommands
      Pop an element from a list, push it to another list and return it; or block until one is available
      Specified by:
      blmove in interface ListCommands
      Parameters:
      srcKey -
      dstKey -
      from - can be LEFT or RIGHT
      to - can be LEFT or RIGHT
      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.
      Returns:
      The element being popped and pushed
    • blpop

      public List<String> blpop(int timeout, String... keys)
      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:
      blpop in interface ListCommands
      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

      public KeyedListElement blpop(double timeout, String... keys)
      Description copied from interface: ListCommands
      The blocking version of ListCommands.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:
      blpop in interface ListCommands
      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

      public List<String> brpop(int timeout, String... keys)
      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:
      brpop in interface ListCommands
      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

      public KeyedListElement brpop(double timeout, String... keys)
      Description copied from interface: ListCommands
      The blocking version of ListCommands.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:
      brpop in interface ListCommands
      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

      public KeyValue<String,List<String>> lmpop(ListDirection direction, String... keys)
      Specified by:
      lmpop in interface ListCommands
    • lmpop

      public KeyValue<String,List<String>> lmpop(ListDirection direction, int count, String... keys)
      Specified by:
      lmpop in interface ListCommands
    • blmpop

      public KeyValue<String,List<String>> blmpop(long timeout, ListDirection direction, String... keys)
      Specified by:
      blmpop in interface ListCommands
    • blmpop

      public KeyValue<String,List<String>> blmpop(long timeout, ListDirection direction, int count, String... keys)
      Specified by:
      blmpop in interface ListCommands
    • bzpopmax

      public KeyedZSetElement bzpopmax(double timeout, String... keys)
      Description copied from interface: SortedSetCommands
      The blocking version of ZPOPMAX
      Specified by:
      bzpopmax in interface SortedSetCommands
      Parameters:
      timeout - specifying the maximum number of seconds to block. A timeout of zero can be used to block indefinitely.
      keys -
    • bzpopmin

      public KeyedZSetElement bzpopmin(double timeout, String... keys)
      Description copied from interface: SortedSetCommands
      The blocking version of ZPOPMIN
      Specified by:
      bzpopmin in interface SortedSetCommands
      Parameters:
      timeout - specifying the maximum number of seconds to block. A timeout of zero can be used to block indefinitely.
      keys -
    • blpop

      public List<String> blpop(int timeout, String key)
      Specified by:
      blpop in interface ListCommands
      See Also:
    • blpop

      public KeyedListElement blpop(double timeout, String key)
      Specified by:
      blpop in interface ListCommands
      See Also:
    • brpop

      public List<String> brpop(int timeout, String key)
      Specified by:
      brpop in interface ListCommands
      See Also:
    • brpop

      public KeyedListElement brpop(double timeout, String key)
      Specified by:
      brpop in interface ListCommands
      See Also:
    • zcount

      public long zcount(String key, double min, double max)
      Description copied from interface: SortedSetCommands
      Return 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:
      zcount in interface SortedSetCommands
      Parameters:
      key - the key to query
      min - minimum score
      max - maximum score
      Returns:
      The number of elements in the specified score range.
    • zcount

      public long zcount(String key, String min, String max)
      Description copied from interface: SortedSetCommands
      Similar to ZCOUNT but with exclusive range.
      Specified by:
      zcount in interface SortedSetCommands
      See Also:
    • zrangeByScore

      public List<String> zrangeByScore(String key, double min, double max)
      Return the all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max).

      The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).

      Using the optional LIMIT it 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 ZCOUNT command is similar to ZRANGEBYSCORE but instead of returning the actual elements in the specified interval, it just returns the number of matching elements.

      Exclusive intervals and infinity

      min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".

      Also while the interval is for default closed (inclusive) it is possible to specify open intervals prefixing the score with a "(" character, so for instance:

      ZRANGEBYSCORE zset (1.3 5

      Will return all the values with score > 1.3 and <= 5, while for instance:

      ZRANGEBYSCORE zset (5 (10

      Will return all the values with score > 5 and < 10 (5 and 10 excluded).

      Time complexity:

      O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))

      Specified by:
      zrangeByScore in interface SortedSetCommands
      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

      public List<String> zrangeByScore(String key, String min, String max)
      Description copied from interface: SortedSetCommands
      Similar to ZRANGE but with exclusive range.
      Specified by:
      zrangeByScore in interface SortedSetCommands
      See Also:
    • zrangeByScore

      public List<String> zrangeByScore(String key, double min, double max, int offset, int count)
      Return the all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max).

      The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).

      Using the optional LIMIT it 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 ZCOUNT command is similar to ZRANGEBYSCORE but instead of returning the actual elements in the specified interval, it just returns the number of matching elements.

      Exclusive intervals and infinity

      min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".

      Also while the interval is for default closed (inclusive) it is possible to specify open intervals prefixing the score with a "(" character, so for instance:

      ZRANGEBYSCORE zset (1.3 5

      Will return all the values with score > 1.3 and <= 5, while for instance:

      ZRANGEBYSCORE zset (5 (10

      Will return all the values with score > 5 and < 10 (5 and 10 excluded).

      Time complexity:

      O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))

      Specified by:
      zrangeByScore in interface SortedSetCommands
      Parameters:
      key -
      min -
      max -
      offset -
      count -
      Returns:
      A list of elements in the specified score range
      See Also:
    • zrangeByScore

      public List<String> zrangeByScore(String key, String min, String max, int offset, int count)
      Description copied from interface: SortedSetCommands
      Similar to ZRANGE but with limit option,
      Specified by:
      zrangeByScore in interface SortedSetCommands
      Parameters:
      key - the key to query
      min - minimum score
      max - maximum score
      offset - the first index of the sub-range
      count - 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

      public List<Tuple> zrangeByScoreWithScores(String key, double min, double max)
      Return the all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max).

      The elements having the same score are returned sorted lexicographically as ASCII strings (this follows from a property of Redis sorted sets and does not involve further computation).

      Using the optional LIMIT it 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 ZCOUNT command is similar to ZRANGEBYSCORE but instead of returning the actual elements in the specified interval, it just returns the number of matching elements.

      Exclusive intervals and infinity

      min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".

      Also while the interval is for default closed (inclusive) it is possible to specify open intervals prefixing the score with a "(" character, so for instance:

      ZRANGEBYSCORE zset (1.3 5

      Will return all the values with score > 1.3 and <= 5, while for instance:

      ZRANGEBYSCORE zset (5 (10

      Will return all the values with score > 5 and < 10 (5 and 10 excluded).

      Time complexity:

      O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))

      Specified by:
      zrangeByScoreWithScores in interface SortedSetCommands
      Parameters:
      key -
      min -
      max -
      Returns:
      A list of elements in the specified score range
      See Also:
    • zrangeByScoreWithScores

      public List<Tuple> zrangeByScoreWithScores(String key, String min, String max)
      Description copied from interface: SortedSetCommands
      Similar to ZRANGE but with exclusive range, and return with scores.
      Specified by:
      zrangeByScoreWithScores in interface SortedSetCommands
      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 LIMIT it 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 ZCOUNT command is similar to ZRANGEBYSCORE but instead of returning the actual elements in the specified interval, it just returns the number of matching elements.

      Exclusive intervals and infinity

      min and max can be -inf and +inf, so that you are not required to know what's the greatest or smallest element in order to take, for instance, elements "up to a given value".

      Also while the interval is for default closed (inclusive) it is possible to specify open intervals prefixing the score with a "(" character, so for instance:

      ZRANGEBYSCORE zset (1.3 5

      Will return all the values with score > 1.3 and <= 5, while for instance:

      ZRANGEBYSCORE zset (5 (10

      Will return all the values with score > 5 and < 10 (5 and 10 excluded).

      Time complexity:

      O(log(N))+O(M) with N being the number of elements in the sorted set and M the number of elements returned by the command, so if M is constant (for instance you always ask for the first ten elements with LIMIT) you can consider it O(log(N))

      Specified by:
      zrangeByScoreWithScores in interface SortedSetCommands
      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: SortedSetCommands
      Similar to ZRANGE but with exclusive range, with limit options and return with scores.
      Specified by:
      zrangeByScoreWithScores in interface SortedSetCommands
      Parameters:
      key - the key to query
      min - minimum score
      max - maximum score
      offset - the first index of the sub-range
      count - 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

      public List<String> zrevrangeByScore(String key, double max, double min)
      Description copied from interface: SortedSetCommands
      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). 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:
      zrevrangeByScore in interface SortedSetCommands
      Parameters:
      key - the key to query
      max - maximum score
      min - minimum score
      Returns:
      A List of elements in the specified score range
    • zrevrangeByScore

      public List<String> zrevrangeByScore(String key, String max, String min)
      Description copied from interface: SortedSetCommands
      Similar to ZREVRANGE but with exclusive range.
      Specified by:
      zrevrangeByScore in interface SortedSetCommands
      See Also:
    • zrevrangeByScore

      public List<String> zrevrangeByScore(String key, double max, double min, int offset, int count)
      Description copied from interface: SortedSetCommands
      Similar to ZRANGE but with limit option,
      Specified by:
      zrevrangeByScore in interface SortedSetCommands
      Parameters:
      key - the key to query
      max - maximum score
      min - minimum score
      offset - the first index of the sub-range
      count - 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, double max, double min)
      Description copied from interface: SortedSetCommands
      Similar to ZREVRANGE but return with scores.
      Specified by:
      zrevrangeByScoreWithScores in interface SortedSetCommands
      Parameters:
      key - the key to query
      max - maximum score
      min - 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: SortedSetCommands
      Similar to ZREVRANGE but with limit options and return with scores.
      Specified by:
      zrevrangeByScoreWithScores in interface SortedSetCommands
      Parameters:
      key - the key to query
      max - maximum score
      min - minimum score
      offset - the first index of the sub-range
      count - 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: SortedSetCommands
      Similar to ZREVRANGE but with exclusive range, with limit options and return with scores.
      Specified by:
      zrevrangeByScoreWithScores in interface SortedSetCommands
      Parameters:
      key - the key to query
      max - maximum score
      min - minimum score
      offset - the first index of the sub-range
      count - 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

      public List<String> zrevrangeByScore(String key, String max, String min, int offset, int count)
      Description copied from interface: SortedSetCommands
      Similar to ZREVRANGE but with limit option,
      Specified by:
      zrevrangeByScore in interface SortedSetCommands
      Parameters:
      key - the key to query
      max - maximum score
      min - minimum score
      offset - the first index of the sub-range
      count - 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)
      Description copied from interface: SortedSetCommands
      Similar to ZREVRANGE but with exclusive range, and return with scores.
      Specified by:
      zrevrangeByScoreWithScores in interface SortedSetCommands
      See Also:
    • zremrangeByRank

      public long zremrangeByRank(String 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:
      zremrangeByRank in interface SortedSetCommands
      Parameters:
      key -
      start -
      stop -
      Returns:
      The number of elements removed
    • zremrangeByScore

      public long zremrangeByScore(String key, double min, double max)
      Remove all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max).

      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:
      zremrangeByScore in interface SortedSetCommands
      Parameters:
      key -
      min -
      max -
      Returns:
      The number of elements removed
    • zremrangeByScore

      public long zremrangeByScore(String key, String min, String max)
      Description copied from interface: SortedSetCommands
      Similar to ZREMRANGE but with limit option.
      Specified by:
      zremrangeByScore in interface SortedSetCommands
      See Also:
    • zunion

      public Set<String> zunion(ZParams params, String... keys)
      Add multiple sorted sets, This command is similar to ZUNIONSTORE, but instead of storing the resulting sorted set, it is returned to the connection.
      Specified by:
      zunion in interface SortedSetCommands
      Parameters:
      params -
      keys -
      Returns:
      A set with members of the resulting set
    • zunionWithScores

      public Set<Tuple> zunionWithScores(ZParams params, String... keys)
      Add multiple sorted sets with scores, This command is similar to ZUNIONSTORE, but instead of storing the resulting sorted set, it is returned to the connection.
      Specified by:
      zunionWithScores in interface SortedSetCommands
      Parameters:
      params -
      keys -
      Returns:
      A set with members of the resulting set with scores
    • zunionstore

      public long zunionstore(String dstkey, String... sets)
      Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. 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 command requires an element to be present in each of the given inputs to be inserted in the result. The ZUNIONSTORE command inserts all elements across all inputs.

      Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.

      With the AGGREGATE option, it 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:
      zunionstore in interface SortedSetCommands
      Parameters:
      dstkey -
      sets -
      Returns:
      The number of elements in the sorted set at dstkey
      See Also:
    • zunionstore

      public long zunionstore(String dstkey, ZParams params, String... sets)
      Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. 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 command requires an element to be present in each of the given inputs to be inserted in the result. The ZUNIONSTORE command inserts all elements across all inputs.

      Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.

      With the AGGREGATE option, it 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:
      zunionstore in interface SortedSetCommands
      Parameters:
      dstkey -
      params -
      sets -
      Returns:
      The number of elements in the sorted set at dstkey
      See Also:
    • zinter

      public Set<String> zinter(ZParams params, String... keys)
      Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the connection.
      Specified by:
      zinter in interface SortedSetCommands
      Parameters:
      params -
      keys -
      Returns:
      A set with members of the resulting set
    • zinterWithScores

      public Set<Tuple> zinterWithScores(ZParams params, String... keys)
      Intersect multiple sorted sets, This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the connection.
      Specified by:
      zinterWithScores in interface SortedSetCommands
      Parameters:
      params -
      keys -
      Returns:
      A set with members of the resulting set with scores
    • zintercard

      public long zintercard(String... keys)
      Description copied from interface: SortedSetCommands
      Similar to ZINTER, 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:
      zintercard in interface SortedSetCommands
      Parameters:
      keys - group of sets
      Returns:
      The number of elements in the resulting intersection
      See Also:
    • zintercard

      public long zintercard(long limit, String... keys)
      Description copied from interface: SortedSetCommands
      Similar to ZINTER, 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:
      zintercard in interface SortedSetCommands
      Parameters:
      limit - If the intersection cardinality reaches limit partway through the computation, the algorithm will exit and yield limit as the cardinality
      keys - group of sets
      Returns:
      The number of elements in the resulting intersection
      See Also:
    • zinterstore

      public long zinterstore(String dstkey, String... sets)
      Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. 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 command requires an element to be present in each of the given inputs to be inserted in the result. The ZUNIONSTORE command inserts all elements across all inputs.

      Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.

      With the AGGREGATE option, it 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:
      zinterstore in interface SortedSetCommands
      Parameters:
      dstkey -
      sets -
      Returns:
      The number of elements in the sorted set at dstkey
      See Also:
    • zinterstore

      public long zinterstore(String dstkey, ZParams params, String... sets)
      Creates a union or intersection of N sorted sets given by keys k1 through kN, and stores it at dstkey. 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 command requires an element to be present in each of the given inputs to be inserted in the result. The ZUNIONSTORE command inserts all elements across all inputs.

      Using the WEIGHTS option, it is possible to add weight to each input sorted set. This means that the score of each element in the sorted set is first multiplied by this weight before being passed to the aggregation. When this option is not given, all weights default to 1.

      With the AGGREGATE option, it 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:
      zinterstore in interface SortedSetCommands
      Parameters:
      dstkey -
      params -
      sets -
      Returns:
      The number of elements in the sorted set at dstkey
      See Also:
    • zlexcount

      public long zlexcount(String key, String min, String max)
      Description copied from interface: SortedSetCommands
      Return 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:
      zlexcount in interface SortedSetCommands
      Parameters:
      key -
      min - minimum value
      max - maximum value
      Returns:
      The number of elements in the specified score range
    • zrangeByLex

      public List<String> zrangeByLex(String key, String min, String max)
      Description copied from interface: SortedSetCommands
      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.

      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:
      zrangeByLex in interface SortedSetCommands
      Parameters:
      key -
      min - minimum value
      max - maximum value
      Returns:
      A List of elements in the specified score range
    • zrangeByLex

      public List<String> zrangeByLex(String key, String min, String max, int offset, int count)
      Description copied from interface: SortedSetCommands
      Similar to ZRANGE but with limit option.
      Specified by:
      zrangeByLex in interface SortedSetCommands
      Parameters:
      key -
      min - minimum value
      max - maximum value
      offset - the first index of the sub-range
      count - 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

      public List<String> zrevrangeByLex(String key, String max, String min)
      Description copied from interface: SortedSetCommands
      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.

      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:
      zrevrangeByLex in interface SortedSetCommands
      Parameters:
      key -
      max - maximum value
      min - minimum value
      Returns:
      A List of elements in the specified score range
    • zrevrangeByLex

      public List<String> zrevrangeByLex(String key, String max, String min, int offset, int count)
      Description copied from interface: SortedSetCommands
      Similar to ZRANGE but with limit option.
      Specified by:
      zrevrangeByLex in interface SortedSetCommands
      Parameters:
      key -
      max - maximum value
      min - minimum value
      offset - the first index of the sub-range
      count - 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

      public long zremrangeByLex(String key, String min, String max)
      Description copied from interface: SortedSetCommands
      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.

      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:
      zremrangeByLex in interface SortedSetCommands
      Parameters:
      key -
      min - minimum value to remove
      max - maximum value to remove
      Returns:
      The number of elements removed
    • zmpop

      public KeyValue<String,List<Tuple>> zmpop(SortedSetOption option, String... keys)
      Specified by:
      zmpop in interface SortedSetCommands
    • zmpop

      public KeyValue<String,List<Tuple>> zmpop(SortedSetOption option, int count, String... keys)
      Specified by:
      zmpop in interface SortedSetCommands
    • bzmpop

      public KeyValue<String,List<Tuple>> bzmpop(long timeout, SortedSetOption option, String... keys)
      Specified by:
      bzmpop in interface SortedSetCommands
    • bzmpop

      public KeyValue<String,List<Tuple>> bzmpop(long timeout, SortedSetOption option, int count, String... keys)
      Specified by:
      bzmpop in interface SortedSetCommands
    • strlen

      public long strlen(String key)
      Description copied from interface: StringCommands
      StrLen Command Return the length of the string value stored at key.
      Specified by:
      strlen in interface StringCommands
      Parameters:
      key -
      Returns:
      The length of the string at key, or 0 when key does not exist
    • strAlgoLCSKeys

      @Deprecated public LCSMatchResult strAlgoLCSKeys(String keyA, String keyB, StrAlgoLCSParams params)
      Deprecated.
      STRALGO LCS command will be removed from Redis 7. LCS can be used instead of this method.
      Calculate the longest common subsequence of keyA and keyB.
      Specified by:
      strAlgoLCSKeys in interface StringCommands
      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

      public LCSMatchResult lcs(String keyA, String keyB, LCSParams params)
      Calculate the longest common subsequence of keyA and keyB.
      Specified by:
      lcs in interface StringCommands
      Parameters:
      keyA -
      keyB -
      params -
      Returns:
      According to LCSParams to decide to return content to fill LCSMatchResult.
    • lpushx

      public long lpushx(String key, String... strings)
      Description copied from interface: ListCommands
      Inserts specified values at the head of the list stored at key. In contrary to LPUSH, no operation will be performed when key does not yet exist.
      Specified by:
      lpushx in interface ListCommands
      Parameters:
      key -
      strings - the strings to push
      Returns:
      The length of the list after the push operation
    • persist

      public long persist(String key)
      Undo a expire at turning the expire key into a normal key.

      Time complexity: O(1)

      Specified by:
      persist in interface KeyCommands
      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(String key, String... strings)
      Description copied from interface: ListCommands
      Inserts specified values at the tail of the list stored at key. In contrary to RPUSH, no operation will be performed when key does not yet exist.
      Specified by:
      rpushx in interface ListCommands
      Parameters:
      key -
      strings - the strings to push
      Returns:
      The length of the list after the push operation
    • echo

      public String echo(String string)
      Specified by:
      echo in interface ServerCommands
    • linsert

      public long linsert(String key, ListPosition where, String pivot, String value)
      Description copied from interface: ListCommands
      Inserts 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:
      linsert in interface ListCommands
      Parameters:
      key -
      where - can be BEFORE or AFTER
      pivot - reference value
      value - the value
      Returns:
      The length of the list after the insert operation, or -1 when the value pivot was not found
    • brpoplpush

      public String brpoplpush(String source, String destination, int timeout)
      Pop a value from a list, push it to another list and return it; or block until one is available
      Specified by:
      brpoplpush in interface ListCommands
      Parameters:
      source -
      destination -
      timeout -
      Returns:
      The element
    • setbit

      public boolean setbit(String key, long offset, boolean value)
      Sets or clears the bit at offset in the string value stored at key
      Specified by:
      setbit in interface BitCommands
      Parameters:
      key -
      offset -
      value -
      Returns:
      The original bit value stored at offset
    • getbit

      public boolean getbit(String key, long offset)
      Returns the bit value at offset in the string value stored at key
      Specified by:
      getbit in interface BitCommands
      Parameters:
      key -
      offset -
      Returns:
      The bit value stored at offset
    • setrange

      public long setrange(String key, long offset, String value)
      Description copied from interface: StringCommands
      SetRange 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:
      setrange in interface StringCommands
      Parameters:
      key -
      offset -
      value -
      Returns:
      The length of the string after it was modified by the command
    • getrange

      public String getrange(String key, long startOffset, long endOffset)
      Description copied from interface: StringCommands
      GetRange 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:
      getrange in interface StringCommands
      Parameters:
      key -
      startOffset -
      endOffset -
      Returns:
      The substring
    • bitpos

      public long bitpos(String key, boolean value)
      Description copied from interface: BitCommands
      Bitpos Command Return the position of the first bit set to 1 or 0 in a string.
      Specified by:
      bitpos in interface BitCommands
      Parameters:
      key -
      value - the bit value
      Returns:
      The position of the first bit set to 1 or 0 according to the request
    • bitpos

      public long bitpos(String key, boolean value, BitPosParams params)
      Description copied from interface: BitCommands
      Bitpos Command Return the position of the first bit set to 1 or 0 in a string.
      Specified by:
      bitpos in interface BitCommands
      Parameters:
      key -
      value - the bit value
      params - BitPosParams
      Returns:
      The position of the first bit set to 1 or 0 according to the request
    • role

      public List<Object> role()
      Description copied from interface: ControlCommands
      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. 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:
      role in interface ControlCommands
      Returns:
      The information on the role of a Redis instance
    • configGet

      public List<String> configGet(String pattern)
      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:
      configGet in interface ConfigCommands
      Parameters:
      pattern -
      Returns:
      Bulk reply.
    • configGet

      public List<String> configGet(String... patterns)
      Description copied from interface: ConfigCommands
      Used to read the configuration parameters of Redis server.
      Specified by:
      configGet in interface ConfigCommands
      Parameters:
      patterns - names of Redis server's configuration
      Returns:
      values of Redis server's configuration
    • configSet

      public String configSet(String parameter, String value)
      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:
      configSet in interface ConfigCommands
      Parameters:
      parameter -
      value -
      Returns:
      OK
    • configSet

      public String configSet(String... parameterValues)
      Specified by:
      configSet in interface ConfigCommands
    • publish

      public long publish(String channel, String message)
    • subscribe

      public void subscribe(JedisPubSub jedisPubSub, String... channels)
    • psubscribe

      public void psubscribe(JedisPubSub jedisPubSub, String... patterns)
    • pubsubChannels

      public List<String> pubsubChannels()
    • pubsubChannels

      public List<String> pubsubChannels(String pattern)
    • pubsubNumPat

      public Long pubsubNumPat()
    • pubsubNumSub

      public Map<String,Long> pubsubNumSub(String... channels)
    • eval

      public Object eval(String script, int keyCount, String... params)
      Description copied from interface: ScriptingKeyCommands
      Eval Command Use to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.
      Specified by:
      eval in interface ScriptingKeyCommands
      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 keys
      params - arguments that can be accessed from the script
      Returns:
      The result of the evaluated script
    • eval

      public Object eval(String script, List<String> keys, List<String> args)
      Description copied from interface: ScriptingKeyCommands
      Eval Command Use to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.
      Specified by:
      eval in interface ScriptingKeyCommands
      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 script
      args - additional arguments should not represent key names and can be accessed by the script
      Returns:
      The result of the evaluated script
    • evalReadonly

      public Object evalReadonly(String script, List<String> keys, List<String> args)
      Description copied from interface: ScriptingKeyCommands
      Readonly version of EVAL
      Specified by:
      evalReadonly in interface ScriptingKeyCommands
      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 script
      args - additional arguments should not represent key names and can be accessed by the script
      Returns:
      The result of the evaluated script
      See Also:
    • eval

      public Object eval(String script)
      Description copied from interface: ScriptingKeyCommands
      Eval Command Use to evaluate scripts using the Lua interpreter built into Redis starting from version 2.6.0.
      Specified by:
      eval in interface ScriptingKeyCommands
      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

      public Object evalsha(String sha1)
      Description copied from interface: ScriptingKeyCommands
      EvalSha Command Similar to 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:
      evalsha in interface ScriptingKeyCommands
      Parameters:
      sha1 - the script
      Returns:
      The result of the evaluated script
      See Also:
    • evalsha

      public Object evalsha(String sha1, List<String> keys, List<String> args)
      Description copied from interface: ScriptingKeyCommands
      EvalSha Command Similar to ScriptingKeyCommands.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:
      evalsha in interface ScriptingKeyCommands
      Parameters:
      sha1 - the script
      Returns:
      The result of the evaluated script
      See Also:
    • evalshaReadonly

      public Object evalshaReadonly(String sha1, List<String> keys, List<String> args)
      Description copied from interface: ScriptingKeyCommands
      Readonly version of EVAL
      Specified by:
      evalshaReadonly in interface ScriptingKeyCommands
      Parameters:
      sha1 - the script
      Returns:
      The result of the evaluated script
      See Also:
    • evalsha

      public Object evalsha(String sha1, int keyCount, String... params)
      Description copied from interface: ScriptingKeyCommands
      EvalSha Command Similar to ScriptingKeyCommands.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:
      evalsha in interface ScriptingKeyCommands
      Parameters:
      sha1 - the script
      Returns:
      The result of the evaluated script
      See Also:
    • scriptExists

      public Boolean scriptExists(String sha1)
      Specified by:
      scriptExists in interface ScriptingControlCommands
    • scriptExists

      public List<Boolean> scriptExists(String... sha1)
      Specified by:
      scriptExists in interface ScriptingControlCommands
    • scriptLoad

      public String scriptLoad(String script)
      Specified by:
      scriptLoad in interface ScriptingControlCommands
    • slowlogGet

      public List<Slowlog> slowlogGet()
      Specified by:
      slowlogGet in interface SlowlogCommands
    • slowlogGet

      public List<Slowlog> slowlogGet(long entries)
      Specified by:
      slowlogGet in interface SlowlogCommands
    • objectRefcount

      public Long objectRefcount(String key)
      Description copied from interface: KeyCommands
      Object Refcount Command Return the reference count of the stored at key.

      Time complexity: O(1)

      Specified by:
      objectRefcount in interface ControlCommands
      Specified by:
      objectRefcount in interface KeyCommands
      Parameters:
      key -
      Returns:
      The number of references
    • objectEncoding

      public String objectEncoding(String key)
      Description copied from interface: KeyCommands
      Object Encoding Command Return the internal encoding for the Redis object stored at key.

      Time complexity: O(1)

      Specified by:
      objectEncoding in interface ControlCommands
      Specified by:
      objectEncoding in interface KeyCommands
      Parameters:
      key -
      Returns:
      The encoding of the object
    • objectIdletime

      public Long objectIdletime(String key)
      Description copied from interface: KeyCommands
      Object IdleTime Command Return the time in seconds since the last access to the value stored at key.

      Time complexity: O(1)

      Specified by:
      objectIdletime in interface ControlCommands
      Specified by:
      objectIdletime in interface KeyCommands
      Parameters:
      key -
      Returns:
      The idle time in seconds
    • objectHelp

      public List<String> objectHelp()
      Description copied from interface: ControlCommands
      Returns the object subcommands and usages.
      Specified by:
      objectHelp in interface ControlCommands
      Returns:
      object subcommands and usages
    • objectFreq

      public Long objectFreq(String key)
      Description copied from interface: KeyCommands
      Object Freq Command Return the logarithmic access frequency counter of a Redis object stored at key.

      Time complexity: O(1)

      Specified by:
      objectFreq in interface ControlCommands
      Specified by:
      objectFreq in interface KeyCommands
      Parameters:
      key -
      Returns:
      The counter's value
    • bitcount

      public long bitcount(String key)
      Description copied from interface: BitCommands
      Bitcount Command Count the number of set bits (population counting) in a string.
      Specified by:
      bitcount in interface BitCommands
      Parameters:
      key -
      Returns:
      The number of bits set to 1
    • bitcount

      public long bitcount(String key, long start, long end)
      Description copied from interface: BitCommands
      Bitcount 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:
      bitcount in interface BitCommands
      Parameters:
      key -
      start - byte start index
      end - byte end index
      Returns:
      The number of bits set to 1
    • bitcount

      public long bitcount(String key, long start, long end, BitCountOption option)
      Specified by:
      bitcount in interface BitCommands
      Parameters:
      key -
      start - byte start index
      end - byte end index
      option - indicate BYTE or BIT
      Returns:
      The number of bits set to 1
      See Also:
    • bitop

      public long bitop(BitOP op, String destKey, String... srcKeys)
      Description copied from interface: BitCommands
      Bitop Command Perform a bitwise operation between multiple keys (containing string values) and store the result in the destKey.
      Specified by:
      bitop in interface BitCommands
      Parameters:
      op - can be AND, OR, XOR or NOT
      destKey -
      srcKeys -
      Returns:
      The size of the string stored in the destKey
    • commandCount

      public long commandCount()
    • commandDocs

      public Map<String,CommandDocument> commandDocs(String... commands)
    • commandGetKeys

      public List<String> commandGetKeys(String... command)
    • commandGetKeysAndFlags

      public List<KeyValue<String,List<String>>> commandGetKeysAndFlags(String... command)
    • commandInfo

      public Map<String,CommandInfo> commandInfo(String... commands)
    • commandList

      public List<String> commandList()
    • commandListFilterBy

      public List<String> commandListFilterBy(CommandListFilterByParams filterByParams)
    • sentinelMyId

      public String sentinelMyId()
      Specified by:
      sentinelMyId in interface SentinelCommands
    • sentinelMasters

      public List<Map<String,String>> 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:
      sentinelMasters in interface SentinelCommands
    • sentinelMaster

      public Map<String,String> sentinelMaster(String masterName)
      Specified by:
      sentinelMaster in interface SentinelCommands
    • sentinelSentinels

      public List<Map<String,String>> sentinelSentinels(String masterName)
      Specified by:
      sentinelSentinels in interface SentinelCommands
    • sentinelGetMasterAddrByName

      public List<String> sentinelGetMasterAddrByName(String masterName)
       redis 127.0.0.1:26381> sentinel get-master-addr-by-name mymaster
       1) "127.0.0.1"
       2) "6379"
       
      Specified by:
      sentinelGetMasterAddrByName in interface SentinelCommands
      Parameters:
      masterName -
      Returns:
      two elements list of strings : host and port.
    • sentinelReset

      public Long sentinelReset(String pattern)
       redis 127.0.0.1:26381> sentinel reset mymaster
       (integer) 1
       
      Specified by:
      sentinelReset in interface SentinelCommands
      Parameters:
      pattern -
    • sentinelSlaves

      @Deprecated public List<Map<String,String>> sentinelSlaves(String masterName)
      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:
      sentinelSlaves in interface SentinelCommands
      Parameters:
      masterName -
    • sentinelReplicas

      public List<Map<String,String>> sentinelReplicas(String masterName)
      Specified by:
      sentinelReplicas in interface SentinelCommands
    • sentinelFailover

      public String sentinelFailover(String masterName)
      Specified by:
      sentinelFailover in interface SentinelCommands
    • sentinelMonitor

      public String sentinelMonitor(String masterName, String ip, int port, int quorum)
      Specified by:
      sentinelMonitor in interface SentinelCommands
    • sentinelRemove

      public String sentinelRemove(String masterName)
      Specified by:
      sentinelRemove in interface SentinelCommands
    • sentinelSet

      public String sentinelSet(String masterName, Map<String,String> parameterMap)
      Specified by:
      sentinelSet in interface SentinelCommands
    • dump

      public byte[] dump(String key)
      Description copied from interface: KeyCommands
      Dump 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:
      dump in interface KeyCommands
      Parameters:
      key -
      Returns:
      The serialized value
    • restore

      public String restore(String key, long ttl, byte[] serializedValue)
      Description copied from interface: KeyCommands
      Restore Command Create a key associated with a value that is obtained by deserializing the provided serialized value (obtained via DUMP).

      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:
      restore in interface KeyCommands
      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

      public String restore(String key, long ttl, byte[] serializedValue, RestoreParams params)
      Description copied from interface: KeyCommands
      Restore Command Create a key associated with a value that is obtained by deserializing the provided serialized value (obtained via DUMP).

      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:
      restore in interface KeyCommands
      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

      public long pttl(String key)
      Description copied from interface: KeyCommands
      PTTL Command The PTTL command returns the remaining time to live in milliseconds of a key that has an EXPIRE set.

      Time complexity: O(1)

      Specified by:
      pttl in interface KeyCommands
      Parameters:
      key -
      Returns:
      TTL in milliseconds, or a negative value in order to signal an error
    • psetex

      public String psetex(String key, long milliseconds, String value)
      PSETEX works exactly like setex(String, long, String) with the sole difference that the expire time is specified in milliseconds instead of seconds. Time complexity: O(1)
      Specified by:
      psetex in interface StringCommands
      Parameters:
      key -
      milliseconds -
      value -
      Returns:
      OK
    • aclSetUser

      public String aclSetUser(String name)
      Description copied from interface: AccessControlLogCommands
      Create an ACL for the specified user with the default rules.
      Specified by:
      aclSetUser in interface AccessControlLogCommands
      Parameters:
      name - user who receives an acl
      Returns:
      A string containing OK on success
      See Also:
    • aclSetUser

      public String aclSetUser(String name, String... params)
      Description copied from interface: AccessControlLogCommands
      Create an ACL for the specified user, while specifying the rules.
      Specified by:
      aclSetUser in interface AccessControlLogCommands
      Parameters:
      name - user who receives an acl
      params - the acl rules for the specified user
      Returns:
      A string containing OK on success
      See Also:
    • aclDelUser

      public long aclDelUser(String name)
      Description copied from interface: AccessControlLogCommands
      Delete the specified user, from the ACL.
      Specified by:
      aclDelUser in interface AccessControlLogCommands
      Parameters:
      name - The username to delete
      Returns:
      The number of users delete
      See Also:
    • aclDelUser

      public long aclDelUser(String name, String... names)
      Description copied from interface: AccessControlLogCommands
      Delete the specified users, from the ACL.
      Specified by:
      aclDelUser in interface AccessControlLogCommands
      Parameters:
      name - The username to delete
      names - Other usernames to delete
      Returns:
      The number of users delete
      See Also:
    • aclGetUser

      public AccessControlUser aclGetUser(String name)
      Description copied from interface: AccessControlLogCommands
      The command returns all the rules defined for an existing ACL user.
      Specified by:
      aclGetUser in interface AccessControlLogCommands
      Parameters:
      name - username
      Returns:
      a list of ACL rule definitions for the user.
    • aclUsers

      public List<String> aclUsers()
      Description copied from interface: AccessControlLogCommands
      Shows a list of all usernames currently configured with access control lists (ACL).
      Specified by:
      aclUsers in interface AccessControlLogCommands
      Returns:
      list of users
      See Also:
    • aclList

      public List<String> aclList()
      Description copied from interface: AccessControlLogCommands
      Returns the currently active ACL rules on the Redis Server
      Specified by:
      aclList in interface AccessControlLogCommands
      Returns:
      An array of ACL rules
      See Also:
    • aclWhoAmI

      public String aclWhoAmI()
      Description copied from interface: AccessControlLogCommands
      Returns the username used to authenticate the current connection.
      Specified by:
      aclWhoAmI in interface AccessControlLogCommands
      Returns:
      The username used for the current connection
      See Also:
    • aclCat

      public List<String> aclCat()
      Description copied from interface: AccessControlLogCommands
      Show the available ACL categories.
      Specified by:
      aclCat in interface AccessControlLogCommands
      Returns:
      the available ACL categories
      See Also:
    • aclCat

      public List<String> aclCat(String category)
      Description copied from interface: AccessControlLogCommands
      Show the available ACLs for a given category.
      Specified by:
      aclCat in interface AccessControlLogCommands
      Parameters:
      category - The category for which to list available ACLs
      Returns:
      the available ACL categories
      See Also:
    • aclLog

      public List<AccessControlLogEntry> aclLog()
      Description copied from interface: AccessControlLogCommands
      Shows the recent ACL security events.
      Specified by:
      aclLog in interface AccessControlLogCommands
      Returns:
      The list of recent security events
      See Also:
    • aclLog

      public List<AccessControlLogEntry> aclLog(int limit)
      Description copied from interface: AccessControlLogCommands
      Shows the recent limit ACL security events.
      Specified by:
      aclLog in interface AccessControlLogCommands
      Parameters:
      limit - The number of results to return
      Returns:
      The list of recent security events
      See Also:
    • aclLoad

      public String aclLoad()
      Description copied from interface: AccessControlLogCommands
      This function tells Redis to reload its external ACL rules, when Redis is configured with an external ACL file
      Specified by:
      aclLoad in interface AccessControlLogBinaryCommands
      Specified by:
      aclLoad in interface AccessControlLogCommands
      Returns:
      OK or error text
      See Also:
    • aclSave

      public String aclSave()
      Description copied from interface: AccessControlLogCommands
      Save the currently defined in-memory ACL to disk.
      Specified by:
      aclSave in interface AccessControlLogBinaryCommands
      Specified by:
      aclSave in interface AccessControlLogCommands
      Returns:
      OK on success
      See Also:
    • aclGenPass

      public String aclGenPass()
      Description copied from interface: AccessControlLogCommands
      Generate a random password
      Specified by:
      aclGenPass in interface AccessControlLogCommands
      Returns:
      A random password
    • aclGenPass

      public String aclGenPass(int bits)
      Description copied from interface: AccessControlLogCommands
      Generate a random password
      Specified by:
      aclGenPass in interface AccessControlLogCommands
      Parameters:
      bits - the number of output bits
      Returns:
      A random password
    • aclDryRun

      public String aclDryRun(String username, String command, String... args)
      Specified by:
      aclDryRun in interface AccessControlLogCommands
    • aclDryRun

      public String aclDryRun(String username, CommandArguments commandArgs)
      Specified by:
      aclDryRun in interface AccessControlLogCommands
    • aclDryRunBinary

      public byte[] aclDryRunBinary(byte[] username, byte[] command, byte[]... args)
      Specified by:
      aclDryRunBinary in interface AccessControlLogBinaryCommands
    • aclDryRunBinary

      public byte[] aclDryRunBinary(byte[] username, CommandArguments commandArgs)
      Specified by:
      aclDryRunBinary in interface AccessControlLogBinaryCommands
    • clientKill

      public String clientKill(String ipPort)
      Description copied from interface: ClientCommands
      Close a given client connection.
      Specified by:
      clientKill in interface ClientCommands
      Parameters:
      ipPort - The ip:port should match a line returned by the CLIENT LIST command (addr field).
      Returns:
      Close success return OK
    • clientGetname

      public String clientGetname()
      Description copied from interface: ClientCommands
      Returns the name of the current connection as set by CLIENT SETNAME
      Specified by:
      clientGetname in interface ClientCommands
      Returns:
      Current connect name
    • clientList

      public String clientList()
      Description copied from interface: ClientCommands
      Returns information and statistics about the client connections server in a mostly human readable format.
      Specified by:
      clientList in interface ClientCommands
      Returns:
      All clients info connected to redis-server
    • clientList

      public String clientList(ClientType type)
      Description copied from interface: ClientCommands
      Returns information and statistics about the client connections server in a mostly human readable format filter by client type.
      Specified by:
      clientList in interface ClientCommands
      Returns:
      All clients info connected to redis-server
    • clientList

      public String clientList(long... clientIds)
      Description copied from interface: ClientCommands
      Returns information and statistics about the client connections server in a mostly human readable format filter by client ids.
      Specified by:
      clientList in interface ClientCommands
      Parameters:
      clientIds - Unique 64-bit client IDs
      Returns:
      All clients info connected to redis-server
    • clientInfo

      public String clientInfo()
      Description copied from interface: ClientCommands
      Returns information and statistics about the current client connection in a mostly human readable format.
      Specified by:
      clientInfo in interface ClientCommands
      Returns:
      Information and statistics about the current client connection
    • clientSetInfo

      public String clientSetInfo(ClientAttributeOption attr, String value)
      Description copied from interface: ClientCommands
      client set info command Since redis 7.2
      Specified by:
      clientSetInfo in interface ClientCommands
      Parameters:
      attr - the attr option
      value - the value
      Returns:
      OK or error
    • clientSetname

      public String clientSetname(String name)
      Description copied from interface: ClientCommands
      Assigns a name to the current connection.
      Specified by:
      clientSetname in interface ClientCommands
      Parameters:
      name - current connection name
      Returns:
      OK if the connection name was successfully set.
    • migrate

      public String migrate(String host, int port, String key, int destinationDb, int timeout)
      Description copied from interface: DatabaseCommands
      Migrate 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:
      migrate in interface DatabaseCommands
      Parameters:
      host - target host
      port - target port
      key - migrate key
      destinationDb - target db
      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

      public String migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, String... keys)
      Description copied from interface: DatabaseCommands
      Migrate 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:
      migrate in interface DatabaseCommands
      Parameters:
      host - target host
      port - target port
      destinationDB - target db
      timeout - the maximum idle time in any moment of the communication with the destination instance in milliseconds.
      params - MigrateParams
      keys - to migrate
      Returns:
      OK on success, or NOKEY if no keys were found in the source instance.
    • migrate

      public String migrate(String host, int port, String key, int timeout)
      Description copied from interface: KeyCommands
      Migrate 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:
      migrate in interface KeyCommands
      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

      public String migrate(String host, int port, int timeout, MigrateParams params, String... keys)
      Description copied from interface: KeyCommands
      Migrate 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:
      migrate in interface KeyCommands
      Parameters:
      host -
      port -
      timeout - the maximum idle time in any moment of the communication with the destination instance in milliseconds.
      params - MigrateParams
      keys -
      Returns:
      OK on success, or NOKEY if no keys were found in the source instance.
    • scan

      public ScanResult<String> scan(String cursor)
      Specified by:
      scan in interface KeyCommands
    • scan

      public ScanResult<String> scan(String cursor, ScanParams params)
      Specified by:
      scan in interface KeyCommands
    • scan

      public ScanResult<String> scan(String cursor, ScanParams params, String type)
      Specified by:
      scan in interface KeyCommands
    • hscan

      public ScanResult<Map.Entry<String,String>> hscan(String key, String cursor, ScanParams params)
      Specified by:
      hscan in interface HashCommands
    • sscan

      public ScanResult<String> sscan(String key, String cursor, ScanParams params)
      Specified by:
      sscan in interface SetCommands
    • zscan

      public ScanResult<Tuple> zscan(String key, String cursor, ScanParams params)
      Specified by:
      zscan in interface SortedSetCommands
    • readonly

      public String readonly()
      Specified by:
      readonly in interface ClusterCommands
    • readwrite

      public String readwrite()
      Specified by:
      readwrite in interface ClusterCommands
    • clusterNodes

      public String clusterNodes()
      Specified by:
      clusterNodes in interface ClusterCommands
    • clusterMeet

      public String clusterMeet(String ip, int port)
      Specified by:
      clusterMeet in interface ClusterCommands
    • clusterReset

      public String clusterReset()
      Specified by:
      clusterReset in interface ClusterCommands
    • clusterReset

      public String clusterReset(ClusterResetType resetType)
      Description copied from interface: ClusterCommands
      resetType can be null for default behavior.
      Specified by:
      clusterReset in interface ClusterCommands
      Parameters:
      resetType -
      Returns:
      OK
    • clusterAddSlots

      public String clusterAddSlots(int... slots)
      Specified by:
      clusterAddSlots in interface ClusterCommands
    • clusterDelSlots

      public String clusterDelSlots(int... slots)
      Specified by:
      clusterDelSlots in interface ClusterCommands
    • clusterInfo

      public String clusterInfo()
      Specified by:
      clusterInfo in interface ClusterCommands
    • clusterGetKeysInSlot

      public List<String> clusterGetKeysInSlot(int slot, int count)
      Specified by:
      clusterGetKeysInSlot in interface ClusterCommands
    • clusterGetKeysInSlotBinary

      public List<byte[]> clusterGetKeysInSlotBinary(int slot, int count)
      Specified by:
      clusterGetKeysInSlotBinary in interface ClusterCommands
    • clusterSetSlotNode

      public String clusterSetSlotNode(int slot, String nodeId)
      Specified by:
      clusterSetSlotNode in interface ClusterCommands
    • clusterSetSlotMigrating

      public String clusterSetSlotMigrating(int slot, String nodeId)
      Specified by:
      clusterSetSlotMigrating in interface ClusterCommands
    • clusterSetSlotImporting

      public String clusterSetSlotImporting(int slot, String nodeId)
      Specified by:
      clusterSetSlotImporting in interface ClusterCommands
    • clusterSetSlotStable

      public String clusterSetSlotStable(int slot)
      Specified by:
      clusterSetSlotStable in interface ClusterCommands
    • clusterForget

      public String clusterForget(String nodeId)
      Specified by:
      clusterForget in interface ClusterCommands
    • clusterFlushSlots

      public String clusterFlushSlots()
      Specified by:
      clusterFlushSlots in interface ClusterCommands
    • clusterKeySlot

      public long clusterKeySlot(String key)
      Specified by:
      clusterKeySlot in interface ClusterCommands
    • clusterCountFailureReports

      public long clusterCountFailureReports(String nodeId)
      Specified by:
      clusterCountFailureReports in interface ClusterCommands
    • clusterCountKeysInSlot

      public long clusterCountKeysInSlot(int slot)
      Specified by:
      clusterCountKeysInSlot in interface ClusterCommands
    • clusterSaveConfig

      public String clusterSaveConfig()
      Specified by:
      clusterSaveConfig in interface ClusterCommands
    • clusterSetConfigEpoch

      public String clusterSetConfigEpoch(long configEpoch)
      Description copied from interface: ClusterCommands
      Set 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:
      clusterSetConfigEpoch in interface ClusterCommands
      Parameters:
      configEpoch -
      Returns:
      OK
    • clusterBumpEpoch

      public String clusterBumpEpoch()
      Description copied from interface: ClusterCommands
      Advance the cluster config epoch.
      Specified by:
      clusterBumpEpoch in interface ClusterCommands
      Returns:
      BUMPED if the epoch was incremented, or STILL if the node already has the greatest config epoch in the cluster.
    • clusterReplicate

      public String clusterReplicate(String nodeId)
      Specified by:
      clusterReplicate in interface ClusterCommands
    • clusterSlaves

      @Deprecated public List<String> clusterSlaves(String nodeId)
      Deprecated.
      Description copied from interface: ClusterCommands
      CLUSTER SLAVES command is deprecated since Redis 5.
      Specified by:
      clusterSlaves in interface ClusterCommands
    • clusterReplicas

      public List<String> clusterReplicas(String nodeId)
      Specified by:
      clusterReplicas in interface ClusterCommands
    • clusterFailover

      public String clusterFailover()
      Specified by:
      clusterFailover in interface ClusterCommands
    • clusterFailover

      public String clusterFailover(ClusterFailoverOption failoverOption)
      Specified by:
      clusterFailover in interface ClusterCommands
    • clusterSlots

      public List<Object> clusterSlots()
      Specified by:
      clusterSlots in interface ClusterCommands
    • clusterMyId

      public String clusterMyId()
      Specified by:
      clusterMyId in interface ClusterCommands
    • clusterMyShardId

      public String clusterMyShardId()
      Specified by:
      clusterMyShardId in interface ClusterCommands
    • clusterLinks

      public List<Map<String,Object>> clusterLinks()
      Description copied from interface: ClusterCommands
      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.
      Specified by:
      clusterLinks in interface ClusterCommands
      Returns:
      the information of all such peer links as an array
      See Also:
    • clusterAddSlotsRange

      public String clusterAddSlotsRange(int... ranges)
      Description copied from interface: ClusterCommands
      Takes a list of slot ranges (specified by start and end slots) to assign to the node
      Specified by:
      clusterAddSlotsRange in interface ClusterCommands
      Parameters:
      ranges - slots range
      Returns:
      OK if the command was successful. Otherwise an error is returned.
    • clusterDelSlotsRange

      public String clusterDelSlotsRange(int... ranges)
      Description copied from interface: ClusterCommands
      Takes a list of slot ranges (specified by start and end slots) to remove to the node.
      Specified by:
      clusterDelSlotsRange in interface ClusterCommands
      Parameters:
      ranges - slots range
      Returns:
      OK if the command was successful. Otherwise an error is returned.
    • asking

      public String asking()
      Specified by:
      asking in interface ClusterCommands
    • pfadd

      public long pfadd(String key, String... elements)
      Specified by:
      pfadd in interface HyperLogLogCommands
    • pfcount

      public long pfcount(String key)
      Specified by:
      pfcount in interface HyperLogLogCommands
    • pfcount

      public long pfcount(String... keys)
      Specified by:
      pfcount in interface HyperLogLogCommands
    • pfmerge

      public String pfmerge(String destkey, String... sourcekeys)
      Specified by:
      pfmerge in interface HyperLogLogCommands
    • fcall

      public Object fcall(String name, List<String> keys, List<String> args)
      Description copied from interface: FunctionCommands
      Invoke a function.
      Specified by:
      fcall in interface FunctionCommands
      Parameters:
      name -
      keys -
      args -
    • fcallReadonly

      public Object fcallReadonly(String name, List<String> keys, List<String> args)
      Description copied from interface: FunctionCommands
      This is a read-only variant of the FCALL command that cannot execute commands that modify data.
      Specified by:
      fcallReadonly in interface FunctionCommands
    • functionDelete

      public String functionDelete(String libraryName)
      Description copied from interface: FunctionCommands
      This 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:
      functionDelete in interface FunctionCommands
      Parameters:
      libraryName -
      Returns:
      OK
    • functionLoad

      public String functionLoad(String functionCode)
      Description copied from interface: FunctionCommands
      Load 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:
      functionLoad in interface FunctionCommands
      Parameters:
      functionCode - the source code.
      Returns:
      The library name that was loaded
    • functionLoadReplace

      public String functionLoadReplace(String functionCode)
      Description copied from interface: FunctionCommands
      Load a library to Redis. Will replace the current library if it already exists.
      Specified by:
      functionLoadReplace in interface FunctionCommands
      Parameters:
      functionCode - the source code
      Returns:
      The library name that was loaded
    • functionStats

      public FunctionStats functionStats()
      Description copied from interface: FunctionCommands
      Return information about the function that's currently running and information about the available execution engines.
      Specified by:
      functionStats in interface FunctionCommands
      Returns:
      FunctionStats
    • functionFlush

      public String functionFlush()
      Description copied from interface: FunctionCommands
      Deletes all the libraries, unless called with the optional mode argument, the 'lazyfree-lazy-user-flush' configuration directive sets the effective behavior.
      Specified by:
      functionFlush in interface FunctionBinaryCommands
      Specified by:
      functionFlush in interface FunctionCommands
      Returns:
      OK
    • functionFlush

      public String functionFlush(FlushMode mode)
      Description copied from interface: FunctionCommands
      Deletes all the libraries, unless called with the optional mode argument, the 'lazyfree-lazy-user-flush' configuration directive sets the effective behavior.
      Specified by:
      functionFlush in interface FunctionBinaryCommands
      Specified by:
      functionFlush in interface FunctionCommands
      Parameters:
      mode - ASYNC: Asynchronously flush the libraries, SYNC: Synchronously flush the libraries.
      Returns:
      OK
    • functionKill

      public String functionKill()
      Description copied from interface: FunctionCommands
      Kill 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:
      functionKill in interface FunctionBinaryCommands
      Specified by:
      functionKill in interface FunctionCommands
      Returns:
      OK
    • functionList

      public List<LibraryInfo> functionList()
      Description copied from interface: FunctionCommands
      Return information about the functions and libraries.
      Specified by:
      functionList in interface FunctionCommands
      Returns:
      LibraryInfo
    • functionList

      public List<LibraryInfo> functionList(String libraryNamePattern)
      Description copied from interface: FunctionCommands
      Return information about the functions and libraries.
      Specified by:
      functionList in interface FunctionCommands
      Parameters:
      libraryNamePattern - a pattern for matching library names
      Returns:
      LibraryInfo
    • functionListWithCode

      public List<LibraryInfo> functionListWithCode()
      Description copied from interface: FunctionCommands
      Similar to FUNCTION LIST but include the libraries source implementation in the reply.
      Specified by:
      functionListWithCode in interface FunctionCommands
      Returns:
      LibraryInfo
      See Also:
    • functionListWithCode

      public List<LibraryInfo> functionListWithCode(String libraryNamePattern)
      Description copied from interface: FunctionCommands
      Similar to FUNCTION LIST but include the libraries source implementation in the reply.
      Specified by:
      functionListWithCode in interface FunctionCommands
      Parameters:
      libraryNamePattern - a pattern for matching library names
      Returns:
      LibraryInfo
      See Also:
    • geoadd

      public long geoadd(String key, double longitude, double latitude, String member)
      Description copied from interface: GeoCommands
      Adds 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:
      geoadd in interface GeoCommands
      Parameters:
      key -
      longitude -
      latitude -
      member -
      Returns:
      The number of elements added
    • geoadd

      public long geoadd(String key, Map<String,GeoCoordinate> memberCoordinateMap)
      Description copied from interface: GeoCommands
      Adds 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:
      geoadd in interface GeoCommands
      Parameters:
      key -
      memberCoordinateMap - Members names with their geo coordinates
      Returns:
      The number of elements added
    • geoadd

      public long geoadd(String key, GeoAddParams params, Map<String,GeoCoordinate> memberCoordinateMap)
      Description copied from interface: GeoCommands
      Adds 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 changed

      Time complexity: O(log(N)) for each item added

      Specified by:
      geoadd in interface GeoCommands
      Parameters:
      key -
      params - Additional options
      memberCoordinateMap - Members names with their geo coordinates
      Returns:
      The number of elements added
    • geodist

      public Double geodist(String key, String member1, String member2)
      Description copied from interface: GeoCommands
      Return the distance between two members in the geospatial index represented by the sorted set.

      Time complexity: O(log(N))

      Specified by:
      geodist in interface GeoCommands
      Parameters:
      key -
      member1 -
      member2 -
      Returns:
      The distance as a double
    • geodist

      public Double geodist(String key, String member1, String member2, GeoUnit unit)
      Description copied from interface: GeoCommands
      Return the distance between two members in the geospatial index represented by the sorted set.

      Time complexity: O(log(N))

      Specified by:
      geodist in interface GeoCommands
      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

      public List<String> geohash(String key, String... members)
      Description copied from interface: GeoCommands
      Return valid Geohash strings representing the position of the given members.

      Time complexity: O(log(N)) for each member requested

      Specified by:
      geohash in interface GeoCommands
      Parameters:
      key -
      members -
      Returns:
      A list of Geohash strings corresponding to each member name passed as argument to the command.
    • geopos

      public List<GeoCoordinate> geopos(String key, String... members)
      Description copied from interface: GeoCommands
      Return the positions (longitude,latitude) of all the specified members.

      Time complexity: O(N) where N is the number of members requested.

      Specified by:
      geopos in interface GeoCommands
      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: GeoCommands
      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.

      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:
      georadius in interface GeoCommands
      Parameters:
      key -
      longitude - of the center point
      latitude - of the center point
      radius - of the area
      unit - 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: GeoCommands
      Readonly version of GEORADIUS,

      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:
      georadiusReadonly in interface GeoCommands
      Parameters:
      key -
      longitude - of the center point
      latitude - of the center point
      radius - of the area
      unit - 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: GeoCommands
      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. Additional information can be reached using GeoRadiusParam: 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:
      georadius in interface GeoCommands
      Parameters:
      key -
      longitude - of the center point
      latitude - of the center point
      radius - of the area
      unit - can be M, KM, MI or FT
      param - 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: GeoCommands
      This command is exactly like GEORADIUS but storing the results at the destination key (provided with storeParam).

      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:
      georadiusStore in interface GeoCommands
      Parameters:
      key -
      longitude - of the center point
      latitude - of the center point
      radius - of the area
      unit - can be M, KM, MI or FT
      param - GeoRadiusParam
      storeParam - 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: GeoCommands
      Readonly version of GEORADIUS,

      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:
      georadiusReadonly in interface GeoCommands
      Parameters:
      key -
      longitude - of the center point
      latitude - of the center point
      radius - of the area
      unit - can be M, KM, MI or FT
      param - GeoRadiusParam
      Returns:
      List of GeoRadiusResponse
      See Also:
    • georadiusByMember

      public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius, GeoUnit unit)
      Description copied from interface: GeoCommands
      This command is exactly like GEORADIUS with 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:
      georadiusByMember in interface GeoCommands
      Parameters:
      key -
      member - represents the center of the area
      radius - of the area
      unit - 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: GeoCommands
      Readonly version of GEORADIUSBYMEMBER

      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:
      georadiusByMemberReadonly in interface GeoCommands
      Parameters:
      key -
      member - represents the center of the area
      radius - of the area
      unit - 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: GeoCommands
      This command is exactly like GEORADIUS with 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:
      georadiusByMember in interface GeoCommands
      Parameters:
      key -
      member - represents the center of the area
      radius - of the area
      unit - can be M, KM, MI or FT
      param - 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: GeoCommands
      This command is exactly like GEORADIUSBYMEMBER but storing the results at the destination key (provided with storeParam).

      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:
      georadiusByMemberStore in interface GeoCommands
      Parameters:
      key -
      member - represents the center of the area
      radius - of the area
      unit - can be M, KM, MI or FT
      param - GeoRadiusParam
      storeParam - 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: GeoCommands
      Readonly version of GEORADIUSBYMEMBER

      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:
      georadiusByMemberReadonly in interface GeoCommands
      Parameters:
      key -
      member - represents the center of the area
      radius - of the area
      unit - can be M, KM, MI or FT
      param - GeoRadiusParam
      Returns:
      List of GeoRadiusResponse
    • geosearch

      public List<GeoRadiusResponse> geosearch(String key, String member, double radius, GeoUnit unit)
      Description copied from interface: GeoCommands
      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.

      This command can be used in place of the GEORADIUSBYMEMBER command.

      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:
      geosearch in interface GeoCommands
      Parameters:
      key -
      member - represents the center of the area
      radius - of the area
      unit - 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: GeoCommands
      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.

      This command can be used in place of the GEORADIUS command.

      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:
      geosearch in interface GeoCommands
      Parameters:
      key -
      coord - represents the center of the area
      radius - of the area
      unit - 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: GeoCommands
      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. 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:
      geosearch in interface GeoCommands
      Parameters:
      key -
      member - represents the center of the area
      width - of the rectangular area
      height - of the rectangular area
      unit - 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: GeoCommands
      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. 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:
      geosearch in interface GeoCommands
      Parameters:
      key -
      coord - represents the center point
      width - of the rectangular area
      height - of the rectangular area
      unit - can be M, KM, MI or FT
      Returns:
      List of GeoRadiusResponse
    • geosearch

      public List<GeoRadiusResponse> geosearch(String key, GeoSearchParam params)
      Description copied from interface: GeoCommands
      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. 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:
      geosearch in interface GeoCommands
      Parameters:
      key -
      params - GeoSearchParam
      Returns:
      List of GeoRadiusResponse
    • geosearchStore

      public long geosearchStore(String dest, String src, String member, double radius, GeoUnit unit)
      Description copied from interface: GeoCommands
      This command is exactly like GEOSEARCH but 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:
      geosearchStore in interface GeoCommands
      Parameters:
      dest -
      src - the sorted set (key)
      member - represents the center of the area
      radius - of the circular area
      unit - 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: GeoCommands
      This command is exactly like GEOSEARCH but 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:
      geosearchStore in interface GeoCommands
      Parameters:
      dest -
      src -
      coord - represents the center point
      radius - of the circular area
      unit - 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: GeoCommands
      This command is exactly like GEOSEARCH but 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:
      geosearchStore in interface GeoCommands
      Parameters:
      dest -
      src -
      member - represents the center of the area
      width - of the rectangular area
      height - of the rectangular area
      unit - 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: GeoCommands
      This command is exactly like GEOSEARCH but 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:
      geosearchStore in interface GeoCommands
      Parameters:
      dest -
      src -
      coord - represents the center point
      width - of the rectangular area
      height - of the rectangular area
      unit - can be M, KM, MI or FT
      Returns:
      The number of results being stored
    • geosearchStore

      public long geosearchStore(String dest, String src, GeoSearchParam params)
      Description copied from interface: GeoCommands
      This command is exactly like GEOSEARCH but 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:
      geosearchStore in interface GeoCommands
      Parameters:
      dest -
      src -
      params - GeoSearchParam
      Returns:
      The number of results being stored
    • geosearchStoreStoreDist

      public long geosearchStoreStoreDist(String dest, String src, GeoSearchParam params)
      Description copied from interface: GeoCommands
      This command is exactly like GEOSEARCHSTORE but 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:
      geosearchStoreStoreDist in interface GeoCommands
      Parameters:
      dest -
      src -
      params - GeoSearchParam
      Returns:
      The number of results being stored
    • moduleLoad

      public String moduleLoad(String path)
      Description copied from interface: ModuleCommands
      Load and initialize the Redis module from the dynamic library specified by the path argument.
      Specified by:
      moduleLoad in interface ModuleCommands
      Parameters:
      path - should be the absolute path of the library, including the full filename
      Returns:
      OK
    • moduleLoad

      public String moduleLoad(String path, String... args)
      Description copied from interface: ModuleCommands
      Load and initialize the Redis module from the dynamic library specified by the path argument.
      Specified by:
      moduleLoad in interface ModuleCommands
      Parameters:
      path - should be the absolute path of the library, including the full filename
      args - additional arguments are passed unmodified to the module
      Returns:
      OK
    • moduleLoadEx

      public String moduleLoadEx(String path, ModuleLoadExParams params)
      Description copied from interface: ModuleCommands
      Loads 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:
      moduleLoadEx in interface ModuleCommands
      Parameters:
      path - should be the absolute path of the library, including the full filename
      params - as in description
      Returns:
      OK
    • moduleUnload

      public String moduleUnload(String name)
      Description copied from interface: ModuleCommands
      Unload the module specified by name. Note that the module's name is reported by the MODULE LIST command, and may differ from the dynamic library's filename.
      Specified by:
      moduleUnload in interface ModuleCommands
      Parameters:
      name -
      Returns:
      OK
    • moduleList

      public List<Module> moduleList()
      Description copied from interface: ModuleCommands
      Return information about the modules loaded to the server.
      Specified by:
      moduleList in interface GenericControlCommands
      Specified by:
      moduleList in interface ModuleCommands
      Returns:
      list of Module
    • bitfield

      public List<Long> bitfield(String key, String... arguments)
      Description copied from interface: BitCommands
      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.
      Specified by:
      bitfield in interface BitCommands
      Parameters:
      key -
      arguments - may be used with optional arguments
      Returns:
      A List of results
    • bitfieldReadonly

      public List<Long> bitfieldReadonly(String key, String... arguments)
      Description copied from interface: BitCommands
      The readonly version of BITFIELD
      Specified by:
      bitfieldReadonly in interface BitCommands
    • hstrlen

      public long hstrlen(String key, String field)
      Specified by:
      hstrlen in interface HashCommands
    • memoryDoctor

      public String memoryDoctor()
      Description copied from interface: ControlCommands
      Reports about different memory-related issues that the Redis server experiences, and advises about possible remedies.
      Specified by:
      memoryDoctor in interface ControlCommands
    • memoryUsage

      public Long memoryUsage(String key)
      Description copied from interface: KeyCommands
      Memory 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:
      memoryUsage in interface ControlCommands
      Specified by:
      memoryUsage in interface KeyCommands
      Parameters:
      key -
      Returns:
      The memory usage in bytes
    • memoryUsage

      public Long memoryUsage(String key, int samples)
      Description copied from interface: KeyCommands
      Memory 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:
      memoryUsage in interface ControlCommands
      Specified by:
      memoryUsage in interface KeyCommands
      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

      public String memoryPurge()
      Description copied from interface: ControlCommands
      Attempts to purge dirty pages so these can be reclaimed by the allocator.
      Specified by:
      memoryPurge in interface ControlCommands
      Returns:
      OK
    • memoryStats

      public Map<String,Object> memoryStats()
      Description copied from interface: ControlCommands
      Returns an Array reply about the memory usage of the server.
      Specified by:
      memoryStats in interface ControlCommands
      Returns:
      nested list of memory usage metrics and their values
    • lolwut

      public String lolwut()
      Specified by:
      lolwut in interface ServerCommands
    • lolwut

      public String lolwut(LolwutParams lolwutParams)
      Specified by:
      lolwut in interface ServerCommands
    • latencyDoctor

      public String latencyDoctor()
      Description copied from interface: ServerCommands
      The 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:
      latencyDoctor in interface ServerCommands
      Returns:
      the report
    • xadd

      public StreamEntryID xadd(String key, StreamEntryID id, Map<String,String> hash)
      Description copied from interface: StreamCommands
      XADD key ID field string [field string ...]
      Specified by:
      xadd in interface StreamCommands
      Returns:
      the ID of the added entry
    • xadd

      public StreamEntryID xadd(String key, XAddParams params, Map<String,String> hash)
      Specified by:
      xadd in interface StreamCommands
    • xlen

      public long xlen(String key)
      Description copied from interface: StreamCommands
      XLEN key
      Specified by:
      xlen in interface StreamCommands
      Returns:
      length of stream
    • xrange

      public List<StreamEntry> xrange(String key, StreamEntryID start, StreamEntryID end)
      Description copied from interface: StreamCommands
      XRANGE key start end
      Specified by:
      xrange in interface StreamCommands
      Parameters:
      key -
      start - minimum StreamEntryID for the retrieved range, passing null will indicate minimum ID possible in the stream
      end - maximum StreamEntryID for the retrieved range, passing null will indicate maximum ID possible in the stream
      Returns:
      The entries with IDs matching the specified range.
    • xrange

      public List<StreamEntry> xrange(String key, StreamEntryID start, StreamEntryID end, int count)
      Description copied from interface: StreamCommands
      XRANGE key start end COUNT count
      Specified by:
      xrange in interface StreamCommands
      Parameters:
      key -
      start - minimum StreamEntryID for the retrieved range, passing null will indicate minimum ID possible in the stream
      end - maximum StreamEntryID for the retrieved range, passing null will indicate maximum ID possible in the stream
      count - maximum number of entries returned
      Returns:
      The entries with IDs matching the specified range.
    • xrevrange

      public List<StreamEntry> xrevrange(String key, StreamEntryID end, StreamEntryID start)
      Description copied from interface: StreamCommands
      XREVRANGE key end start
      Specified by:
      xrevrange in interface StreamCommands
      Parameters:
      key -
      end - maximum StreamEntryID for the retrieved range, passing null will indicate maximum ID possible in the stream
      start - minimum StreamEntryID for the retrieved range, passing null will 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

      public List<StreamEntry> xrevrange(String key, StreamEntryID end, StreamEntryID start, int count)
      Description copied from interface: StreamCommands
      XREVRANGE key end start COUNT count
      Specified by:
      xrevrange in interface StreamCommands
      Parameters:
      key -
      end - maximum StreamEntryID for the retrieved range, passing null will indicate maximum ID possible in the stream
      start - minimum StreamEntryID for the retrieved range, passing null will indicate minimum ID possible in the stream
      count - 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

      public List<StreamEntry> xrange(String key, String start, String end)
      Specified by:
      xrange in interface StreamCommands
    • xrange

      public List<StreamEntry> xrange(String key, String start, String end, int count)
      Specified by:
      xrange in interface StreamCommands
    • xrevrange

      public List<StreamEntry> xrevrange(String key, String end, String start)
      Specified by:
      xrevrange in interface StreamCommands
    • xrevrange

      public List<StreamEntry> xrevrange(String key, String end, String start, int count)
      Specified by:
      xrevrange in interface StreamCommands
    • xread

      public List<Map.Entry<String,List<StreamEntry>>> xread(XReadParams xReadParams, Map<String,StreamEntryID> streams)
      Description copied from interface: StreamCommands
      XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]
      Specified by:
      xread in interface StreamCommands
    • xack

      public long xack(String key, String group, StreamEntryID... ids)
      Description copied from interface: StreamCommands
      XACK key group ID [ID ...]
      Specified by:
      xack in interface StreamCommands
    • xgroupCreate

      public String xgroupCreate(String key, String groupName, StreamEntryID id, boolean makeStream)
      Description copied from interface: StreamCommands
      XGROUP CREATE key groupName <id or $>
      Specified by:
      xgroupCreate in interface StreamCommands
    • xgroupSetID

      public String xgroupSetID(String key, String groupName, StreamEntryID id)
      Description copied from interface: StreamCommands
      XGROUP SETID key groupName <id or $>
      Specified by:
      xgroupSetID in interface StreamCommands
    • xgroupDestroy

      public long xgroupDestroy(String key, String groupName)
      Description copied from interface: StreamCommands
      XGROUP DESTROY key groupName
      Specified by:
      xgroupDestroy in interface StreamCommands
    • xgroupCreateConsumer

      public boolean xgroupCreateConsumer(String key, String groupName, String consumerName)
      Description copied from interface: StreamCommands
      XGROUP CREATECONSUMER key groupName consumerName
      Specified by:
      xgroupCreateConsumer in interface StreamCommands
    • xgroupDelConsumer

      public long xgroupDelConsumer(String key, String groupName, String consumerName)
      Description copied from interface: StreamCommands
      XGROUP DELCONSUMER key groupName consumerName
      Specified by:
      xgroupDelConsumer in interface StreamCommands
    • xdel

      public long xdel(String key, StreamEntryID... ids)
      Description copied from interface: StreamCommands
      XDEL key ID [ID ...]
      Specified by:
      xdel in interface StreamCommands
    • xtrim

      public long xtrim(String key, long maxLen, boolean approximateLength)
      Description copied from interface: StreamCommands
      XTRIM key MAXLEN [~] count
      Specified by:
      xtrim in interface StreamCommands
    • xtrim

      public long xtrim(String key, XTrimParams params)
      Description copied from interface: StreamCommands
      XTRIM key MAXLEN|MINID [=|~] threshold [LIMIT count]
      Specified by:
      xtrim in interface StreamCommands
    • xreadGroup

      public List<Map.Entry<String,List<StreamEntry>>> xreadGroup(String groupName, String consumer, XReadGroupParams xReadGroupParams, Map<String,StreamEntryID> streams)
      Description copied from interface: StreamCommands
      XREAD [COUNT count] [BLOCK milliseconds] STREAMS key [key ...] ID [ID ...]
      Specified by:
      xreadGroup in interface StreamCommands
    • xpending

      public StreamPendingSummary xpending(String key, String groupName)
      Description copied from interface: StreamCommands
      XPENDING key group
      Specified by:
      xpending in interface StreamCommands
    • xpending

      @Deprecated public List<StreamPendingEntry> xpending(String key, String groupName, StreamEntryID start, StreamEntryID end, int count, String consumerName)
      Description copied from interface: StreamCommands
      XPENDING key group [start end count] [consumer]
      Specified by:
      xpending in interface StreamCommands
    • xpending

      public List<StreamPendingEntry> xpending(String key, String groupName, XPendingParams params)
      Description copied from interface: StreamCommands
      XPENDING key group [[IDLE min-idle-time] start end count [consumer]]
      Specified by:
      xpending in interface StreamCommands
    • xclaim

      public List<StreamEntry> xclaim(String key, String group, String consumerName, long minIdleTime, XClaimParams params, StreamEntryID... ids)
      Description copied from interface: StreamCommands
      XCLAIM key group consumer min-idle-time <ID-1> ... <ID-N> [IDLE <milliseconds>] [TIME <mstime>] [RETRYCOUNT <count>] [FORCE]
      Specified by:
      xclaim in interface StreamCommands
    • xclaimJustId

      public List<StreamEntryID> xclaimJustId(String key, String group, String consumerName, long minIdleTime, XClaimParams params, StreamEntryID... ids)
      Description copied from interface: StreamCommands
      XCLAIM key group consumer min-idle-time <ID-1> ... <ID-N> [IDLE <milliseconds>] [TIME <mstime>] [RETRYCOUNT <count>] [FORCE] JUSTID
      Specified by:
      xclaimJustId in interface StreamCommands
    • xautoclaim

      public Map.Entry<StreamEntryID,List<StreamEntry>> xautoclaim(String key, String group, String consumerName, long minIdleTime, StreamEntryID start, XAutoClaimParams params)
      Description copied from interface: StreamCommands
      XAUTOCLAIM key group consumer min-idle-time start [COUNT count]
      Specified by:
      xautoclaim in interface StreamCommands
      Parameters:
      key - Stream Key
      group - Consumer Group
      consumerName - Consumer name to transfer the auto claimed entries
      minIdleTime - Entries pending more than minIdleTime will be transferred ownership
      start - StreamEntryID - Entries ≥ start will be transferred ownership, passing null will 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: StreamCommands
      XAUTOCLAIM key group consumer min-idle-time start [COUNT count] JUSTID
      Specified by:
      xautoclaimJustId in interface StreamCommands
      Parameters:
      key - Stream Key
      group - Consumer Group
      consumerName - Consumer name to transfer the auto claimed entries
      minIdleTime - Entries pending more than minIdleTime will be transferred ownership
      start - StreamEntryID - Entries ≥ start will be transferred ownership, passing null will indicate '-'
      params - XAutoClaimParams
    • xinfoStream

      public StreamInfo xinfoStream(String key)
      Description copied from interface: StreamCommands
      Introspection command used in order to retrieve different information about the stream
      Specified by:
      xinfoStream in interface StreamCommands
      Parameters:
      key - Stream name
      Returns:
      StreamInfo that contains information about the stream
    • xinfoStreamFull

      public StreamFullInfo xinfoStreamFull(String key)
      Description copied from interface: StreamCommands
      Introspection command used in order to retrieve all information about the stream
      Specified by:
      xinfoStreamFull in interface StreamCommands
      Parameters:
      key - Stream name
      Returns:
      StreamFullInfo that contains information about the stream
    • xinfoStreamFull

      public StreamFullInfo xinfoStreamFull(String key, int count)
      Description copied from interface: StreamCommands
      Introspection command used in order to retrieve all information about the stream
      Specified by:
      xinfoStreamFull in interface StreamCommands
      Parameters:
      key - Stream name
      count - stream info count
      Returns:
      StreamFullInfo that contains information about the stream
    • xinfoGroup

      @Deprecated public List<StreamGroupInfo> xinfoGroup(String key)
      Deprecated.
      Specified by:
      xinfoGroup in interface StreamCommands
    • xinfoGroups

      public List<StreamGroupInfo> xinfoGroups(String key)
      Description copied from interface: StreamCommands
      Introspection command used in order to retrieve different information about groups in the stream
      Specified by:
      xinfoGroups in interface StreamCommands
      Parameters:
      key - Stream name
      Returns:
      List of StreamGroupInfo containing information about groups
    • xinfoConsumers

      public List<StreamConsumersInfo> xinfoConsumers(String key, String group)
      Description copied from interface: StreamCommands
      Introspection command used in order to retrieve different information about consumers in the group
      Specified by:
      xinfoConsumers in interface StreamCommands
      Parameters:
      key - Stream name
      group - Group name
      Returns:
      List of StreamConsumersInfo containing information about consumers that belong to the the group
    • fcall

      public Object fcall(byte[] name, List<byte[]> keys, List<byte[]> args)
      Description copied from interface: FunctionBinaryCommands
      Invoke a function.
      Specified by:
      fcall in interface FunctionBinaryCommands
      Parameters:
      name -
      keys -
      args -
      Returns:
    • fcallReadonly

      public Object fcallReadonly(byte[] name, List<byte[]> keys, List<byte[]> args)
      Specified by:
      fcallReadonly in interface FunctionBinaryCommands
    • functionDelete

      public String functionDelete(byte[] libraryName)
      Description copied from interface: FunctionBinaryCommands
      This 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:
      functionDelete in interface FunctionBinaryCommands
      Parameters:
      libraryName -
      Returns:
      OK
    • functionDump

      public byte[] functionDump()
      Description copied from interface: FunctionCommands
      Return the serialized payload of loaded libraries. You can restore the serialized payload later with the FUNCTION RESTORE command.
      Specified by:
      functionDump in interface FunctionBinaryCommands
      Specified by:
      functionDump in interface FunctionCommands
      Returns:
      the serialized payload
    • functionListBinary

      public List<Object> functionListBinary()
      Description copied from interface: FunctionBinaryCommands
      Return information about the functions and libraries.
      Specified by:
      functionListBinary in interface FunctionBinaryCommands
      Returns:
      LibraryInfo
    • functionList

      public List<Object> functionList(byte[] libraryNamePattern)
      Description copied from interface: FunctionBinaryCommands
      Return information about the functions and libraries.
      Specified by:
      functionList in interface FunctionBinaryCommands
      Parameters:
      libraryNamePattern - a pattern for matching library names
      Returns:
      LibraryInfo
    • functionListWithCodeBinary

      public List<Object> functionListWithCodeBinary()
      Description copied from interface: FunctionBinaryCommands
      Similar to FUNCTION LIST but include the libraries source implementation in the reply.
      Specified by:
      functionListWithCodeBinary in interface FunctionBinaryCommands
      Returns:
      LibraryInfo
      See Also:
    • functionListWithCode

      public List<Object> functionListWithCode(byte[] libraryNamePattern)
      Description copied from interface: FunctionBinaryCommands
      Similar to FUNCTION LIST but include the libraries source implementation in the reply.
      Specified by:
      functionListWithCode in interface FunctionBinaryCommands
      Parameters:
      libraryNamePattern - a pattern for matching library names
      Returns:
      LibraryInfo
      See Also:
    • functionLoad

      public String functionLoad(byte[] functionCode)
      Description copied from interface: FunctionBinaryCommands
      Load 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:
      functionLoad in interface FunctionBinaryCommands
      Parameters:
      functionCode - the source code.
      Returns:
      The library name that was loaded
    • functionLoadReplace

      public String functionLoadReplace(byte[] functionCode)
      Description copied from interface: FunctionBinaryCommands
      Load a library to Redis. Will replace the current library if it already exists.
      Specified by:
      functionLoadReplace in interface FunctionBinaryCommands
      Parameters:
      functionCode - the source code
      Returns:
      The library name that was loaded
    • functionRestore

      public String functionRestore(byte[] serializedValue)
      Description copied from interface: FunctionCommands
      Restore libraries from the serialized payload. Default policy is APPEND.
      Specified by:
      functionRestore in interface FunctionBinaryCommands
      Specified by:
      functionRestore in interface FunctionCommands
      Parameters:
      serializedValue - the serialized payload
      Returns:
      OK
    • functionRestore

      public String functionRestore(byte[] serializedValue, FunctionRestorePolicy policy)
      Description copied from interface: FunctionCommands
      Restore libraries from the serialized payload.
      Specified by:
      functionRestore in interface FunctionBinaryCommands
      Specified by:
      functionRestore in interface FunctionCommands
      Parameters:
      serializedValue - the serialized payload
      policy - can be FLUSH, APPEND or REPLACE
      Returns:
      OK
    • functionStatsBinary

      public Object functionStatsBinary()
      Description copied from interface: FunctionBinaryCommands
      Return information about the function that's currently running and information about the available execution engines.
      Specified by:
      functionStatsBinary in interface FunctionBinaryCommands
      Returns:
      FunctionStats
    • sendCommand

      public Object sendCommand(ProtocolCommand cmd, String... args)
    • sendBlockingCommand

      public Object sendBlockingCommand(ProtocolCommand cmd, String... args)
    • 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

      private static String[] joinParameters(String first, String[] rest)
    • joinParameters

      private static String[] joinParameters(String first, String second, String[] rest)