Interface DatabaseCommands

All Known Implementing Classes:
Jedis

public interface DatabaseCommands
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    copy(byte[] srcKey, byte[] dstKey, int db, boolean replace)
    Binary version of COPY.
    boolean
    copy(String srcKey, String dstKey, int db, boolean replace)
    Copy the value stored at the source key to the destination key.
    long
    Return the number of keys in the currently-selected database.
    Delete all the keys of the currently selected DB.
    flushDB(FlushMode flushMode)
    Delete all the keys of the currently selected DB.
    migrate(String host, int port, byte[] key, int destinationDB, int timeout)
    Binary version of MIGRATE.
    migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, byte[]... keys)
    Binary version of MIGRATE.
    migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, String... keys)
    Migrate Command Atomically transfer a key from a source Redis instance to a destination Redis instance.
    migrate(String host, int port, String key, int destinationDB, int timeout)
    Migrate Command Atomically transfer a key from a source Redis instance to a destination Redis instance.
    long
    move(byte[] key, int dbIndex)
    Binary version of MOVE.
    long
    move(String key, int dbIndex)
    Move the specified key from the currently selected DB to the specified destination DB.
    select(int index)
    Select the DB with having the specified zero-based numeric index.
    swapDB(int index1, int index2)
    This command swaps two Redis databases, so that immediately all the clients connected to a given database will see the data of the other database, and the other way around.
  • Method Details

    • select

      String select(int index)
      Select the DB with having the specified zero-based numeric index.
      Parameters:
      index - the index
      Returns:
      OK
    • dbSize

      long dbSize()
      Return the number of keys in the currently-selected database.
      Returns:
      The number of keys
    • flushDB

      String flushDB()
      Delete all the keys of the currently selected DB. This command never fails. The time-complexity for this operation is O(N), N being the number of keys in the database.
      Returns:
      OK
    • flushDB

      String flushDB(FlushMode flushMode)
      Delete all the keys of the currently selected DB. This command never fails. The time-complexity for this operation is O(N), N being the number of keys in the database.
      Parameters:
      flushMode - can be SYNC or ASYNC
      Returns:
      OK
    • swapDB

      String swapDB(int index1, int index2)
      This command swaps two Redis databases, so that immediately all the clients connected to a given database will see the data of the other database, and the other way around.
      Parameters:
      index1 -
      index2 -
      Returns:
      OK
    • move

      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.
      Parameters:
      key - The specified key
      dbIndex - Specified destination database
      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
    • move

      long move(byte[] key, int dbIndex)
      Binary version of MOVE.
      See Also:
    • copy

      boolean copy(String srcKey, String dstKey, int db, boolean replace)
      Copy the value stored at the source key to the destination key.
      Parameters:
      srcKey - the source key.
      dstKey - the destination key.
      db - allows specifying an alternative logical database index for the destination key.
      replace - removes the destination key before copying the value to it, in order to avoid error.
    • copy

      boolean copy(byte[] srcKey, byte[] dstKey, int db, boolean replace)
      Binary version of COPY.
      See Also:
    • migrate

      String migrate(String host, int port, String key, int destinationDB, int timeout)
      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.
      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

      String migrate(String host, int port, byte[] key, int destinationDB, int timeout)
      Binary version of MIGRATE.
      See Also:
    • migrate

      String migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, String... keys)
      Migrate Command Atomically transfer a key from a source Redis instance to a destination Redis instance. On success the key is deleted from the original instance and is guaranteed to exist in the target instance.
      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

      String migrate(String host, int port, int destinationDB, int timeout, MigrateParams params, byte[]... keys)
      Binary version of MIGRATE.
      See Also: