Interface BasicCommands

  • All Known Implementing Classes:
    BinaryJedis, Jedis

    public interface BasicCommands
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      String auth​(String password)
      Request for authentication in a password-protected Redis server.
      String auth​(String user, String password)
      Request for authentication with username and password, based on the ACL feature introduced in Redis 6.0 see https://redis.io/topics/acl
      String bgrewriteaof()
      Instruct Redis to start an Append Only File rewrite process.
      String bgsave()
      Save the DB in background.
      String configResetStat()  
      String configRewrite()  
      Long dbSize()
      Return the number of keys in the currently-selected database.
      String debug​(DebugParams params)  
      String flushAll()
      Delete all the keys of all the existing databases, not just the currently selected one.
      String flushDB()
      Delete all the keys of the currently selected DB.
      int getDB()
      Return the index of the current database
      String info()
      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.
      String info​(String section)
      The INFO command returns information and statistics about the server in a format that is simple to parse by computers and easy to read by humans.
      Long lastsave()
      Return the UNIX TIME of the last DB save executed with success.
      String ping()
      This command is often used to test if a connection is still alive, or to measure latency.
      String quit()
      Ask the server to close the connection.
      String save()
      The SAVE commands performs a synchronous save of the dataset producing a point in time snapshot of all the data inside the Redis instance, in the form of an RDB file.
      String select​(int index)
      Select the DB with having the specified zero-based numeric index.
      String shutdown()
      Stop all the client.
      String slaveof​(String host, int port)
      The SLAVEOF command can change the replication settings of a slave on the fly.
      String slaveofNoOne()
      SLAVEOF NO ONE will stop replication, turning the server into a MASTER, but will not discard the replication.
      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.
      Long waitReplicas​(int replicas, long timeout)
      Blocks until all the previous write commands are successfully transferred and acknowledged by at least the specified number of replicas.
    • Method Detail

      • ping

        String ping()
        This command is often used to test if a connection is still alive, or to measure latency.
        Returns:
        PONG
      • quit

        String quit()
        Ask the server to close the connection. The connection is closed as soon as all pending replies have been written to the client.
        Returns:
        OK
      • 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
      • dbSize

        Long dbSize()
        Return the number of keys in the currently-selected database.
        Returns:
        the number of key in the currently-selected database.
      • select

        String select​(int index)
        Select the DB with having the specified zero-based numeric index.
        Parameters:
        index - the index
        Returns:
        a simple string reply 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:
        Simple string reply: OK if SWAPDB was executed correctly.
      • flushAll

        String flushAll()
        Delete all the keys of all the existing databases, not just the currently selected one.
        Returns:
        a simple string reply (OK)
      • auth

        String auth​(String password)
        Request for authentication in a password-protected Redis server. Redis can be instructed to require a password before allowing clients to execute commands. This is done using the requirepass directive in the configuration file. If password matches the password in the configuration file, the server replies with the OK status code and starts accepting commands. Otherwise, an error is returned and the clients needs to try a new password.
        Parameters:
        password -
        Returns:
        the result of the auth
      • auth

        String auth​(String user,
                    String password)
        Request for authentication with username and password, based on the ACL feature introduced in Redis 6.0 see https://redis.io/topics/acl
        Parameters:
        user -
        password -
        Returns:
      • save

        String save()
        The SAVE commands performs a synchronous save of the dataset producing a point in time snapshot of all the data inside the Redis instance, in the form of an RDB file. You almost never want to call SAVE in production environments where it will block all the other clients. Instead usually BGSAVE is used. However in case of issues preventing Redis to create the background saving child (for instance errors in the fork(2) system call), the SAVE command can be a good last resort to perform the dump of the latest dataset.
        Returns:
        result of the save
      • bgsave

        String bgsave()
        Save the DB in background. The OK code is immediately returned. Redis forks, the parent continues to serve the clients, the child saves the DB on disk then exits. A client may be able to check if the operation succeeded using the LASTSAVE command.
        Returns:
        ok
      • bgrewriteaof

        String bgrewriteaof()
        Instruct Redis to start an Append Only File rewrite process. The rewrite will create a small optimized version of the current Append Only File If BGREWRITEAOF fails, no data gets lost as the old AOF will be untouched. The rewrite will be only triggered by Redis if there is not already a background process doing persistence. Specifically: If a Redis child is creating a snapshot on disk, the AOF rewrite is scheduled but not started until the saving child producing the RDB file terminates. In this case the BGREWRITEAOF will still return an OK code, but with an appropriate message. You can check if an AOF rewrite is scheduled looking at the INFO command as of Redis 2.6. If an AOF rewrite is already in progress the command returns an error and no AOF rewrite will be scheduled for a later time. Since Redis 2.4 the AOF rewrite is automatically triggered by Redis, however the BGREWRITEAOF command can be used to trigger a rewrite at any time.
        Returns:
        the response of the command
      • lastsave

        Long lastsave()
        Return the UNIX TIME of the last DB save executed with success.
        Returns:
        the unix latest save
      • shutdown

        String shutdown()
        Stop all the client. Perform a SAVE (if one save point is configured). Flush the append only file if AOF is enabled quit the server
        Returns:
        only in case of error.
      • info

        String info()
        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.
        Returns:
        information on the server
      • info

        String info​(String section)
        The INFO command returns information and statistics about the server in a format that is simple to parse by computers and easy to read by humans.
        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:
      • slaveof

        String slaveof​(String host,
                       int port)
        The SLAVEOF command can change the replication settings of a slave on the fly. In the proper form SLAVEOF hostname port will make the server a slave of another 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.
        Parameters:
        host - listening at the specified hostname
        port - server listening at the specified port
        Returns:
        result of the command.
      • slaveofNoOne

        String slaveofNoOne()
        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.
        Returns:
        result of the command
      • getDB

        int getDB()
        Return the index of the current database
        Returns:
        the int of the index database.
      • configResetStat

        String configResetStat()
      • configRewrite

        String configRewrite()
      • waitReplicas

        Long waitReplicas​(int replicas,
                          long timeout)
        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.
        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