Class RedisServerConnection

    • Constructor Detail

      • RedisServerConnection

        public RedisServerConnection()
                              throws IOException
        Creates an open connection to localhost, port 6379, the default Redis port.
        Throws:
        IOException - if an I/O error occurs when creating the socket.
        UnknownHostException - if the IP address of the host could not be determined.
        SecurityException - if a security manager exists and doesn't allow the connection to be made.
      • RedisServerConnection

        public RedisServerConnection​(String host,
                                     int port)
                              throws IOException
        Creates an open connection.
        Parameters:
        host - the server hostname or address.
        port - the server connection port.
        Throws:
        IOException - if an I/O error occurs when creating the socket.
        UnknownHostException - if the IP address of the host could not be determined.
        SecurityException - if a security manager exists and doesn't allow the connection to be made.
      • RedisServerConnection

        public RedisServerConnection​(String host,
                                     int port,
                                     String password)
                              throws IOException
        Creates an open connection.
        Parameters:
        host - the server hostname or address.
        port - the server connection port.
        password - the server database password.
        Throws:
        IOException - if an I/O error occurs when creating the socket.
        UnknownHostException - if the IP address of the host could not be determined.
        SecurityException - if a security manager exists and doesn't allow the connection to be made.
        RedisException - if the password in the server information is incorrect.
      • RedisServerConnection

        public RedisServerConnection​(RedisInfo info)
                              throws IOException
        Creates an open connection.
        Parameters:
        info - the RedisInfo class detailing a connection.
        Throws:
        IOException - if an I/O error occurs when creating the socket.
        UnknownHostException - if the IP address of the host could not be determined.
        SecurityException - if a security manager exists and doesn't allow the connection to be made.
        RedisException - if the password in the server information is incorrect.
    • Method Detail

      • clientKill

        public boolean clientKill​(String ip,
                                  int port)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/client-kill:

        Available since 2.4.0.

        Time complexity: O(N) where N is the number of client connections

        The CLIENT KILL command closes a given client connection identified by ip:port.

        Specified by:
        clientKill in interface RedisServerCommands
        Parameters:
        ip - the IP address or hostname.
        port - the port number.
        Returns:
        true once the client connection was closed.
      • clientList

        public String[] clientList()
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/client-list:

        Available since 2.4.0.

        Time complexity: O(N) where N is the number of client connections

        The CLIENT LIST command returns information and statistics about the client connections server in a mostly human readable format.

        Specified by:
        clientList in interface RedisServerCommands
        Returns:
        a list of client strings that describe each connection.
      • clientPause

        public boolean clientPause​(long millis)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/client-pause:

        Available since 2.9.50.

        Time complexity: O(1)

        CLIENT PAUSE is a connections control command able to suspend all the Redis clients for the specified amount of time (in milliseconds).

        Specified by:
        clientPause in interface RedisServerCommands
        Parameters:
        millis - the amount of time in milliseconds.
        Returns:
        always true.
      • configGet

        public String configGet​(String configKey)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/config-get:

        Available since 2.0.0.

        The CONFIG GET command is used to read the configuration parameters of a running Redis server. Not all the configuration parameters are supported in Redis 2.4, while Redis 2.6 can read the whole configuration of a server using this command.

        Specified by:
        configGet in interface RedisServerCommands
        Parameters:
        configKey - the config key.
        Returns:
        the config value.
      • configSet

        public boolean configSet​(String parameter,
                                 String value)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/config-set:

        Available since 2.0.0.

        The CONFIG SET command is used in order to reconfigure the server at run time without the need to restart Redis. You can change both trivial parameters or switch from one to another persistence option using this command.

        Specified by:
        configSet in interface RedisServerCommands
        Parameters:
        parameter - the parameter.
        value - the value.
        Returns:
        always true.
      • info

        public String info​(String section)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/info:

        Available since 1.0.0.

        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 RedisServerCommands
        Parameters:
        section - the section to get info on.
        Returns:
        a collection of text lines parseable for info.
      • object

        public RedisObject object​(String subcommand,
                                  String key)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/object:

        Available since 2.2.3.

        Time complexity: O(1).

        The object command allows to inspect the internals of Redis Objects associated with keys. It is useful for debugging or to understand if your keys are using the specially encoded data types to save space. Your application may also use the information reported by the object command to implement application level key eviction policies when using Redis as a Cache.

        This call is here in order to support commands that don't have signatures.

        Specified by:
        object in interface RedisServerCommands
        Parameters:
        subcommand - the object subcommand.
        key - the key to operate on.
        Returns:
        the Redis object returned.
      • objectRefcount

        public long objectRefcount​(String key)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/object:

        Available since 2.2.3.

        Time complexity: O(1).

        The object command allows to inspect the internals of Redis Objects associated with keys. It is useful for debugging or to understand if your keys are using the specially encoded data types to save space. Your application may also use the information reported by the object command to implement application level key eviction policies when using Redis as a Cache.

        Specified by:
        objectRefcount in interface RedisServerCommands
        Parameters:
        key - the key to count.
        Returns:
        the number of references of the value associated with the specified key. This command is mainly useful for debugging.
      • objectEncoding

        public EncodingType objectEncoding​(String key)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/object:

        Available since 2.2.3.

        Time complexity: O(1).

        The object command allows to inspect the internals of Redis Objects associated with keys. It is useful for debugging or to understand if your keys are using the specially encoded data types to save space. Your application may also use the information reported by the object command to implement application level key eviction policies when using Redis as a Cache.

        Specified by:
        objectEncoding in interface RedisServerCommands
        Parameters:
        key - the key to inspect.
        Returns:
        the kind of internal representation used in order to store the value associated with a key, or null for missing key.
      • objectIdletime

        public long objectIdletime​(String key)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/object:

        Available since 2.2.3.

        Time complexity: O(1).

        The object command allows to inspect the internals of Redis Objects associated with keys. It is useful for debugging or to understand if your keys are using the specially encoded data types to save space. Your application may also use the information reported by the object command to implement application level key eviction policies when using Redis as a Cache.

        Specified by:
        objectIdletime in interface RedisServerCommands
        Parameters:
        key - the key to inspect.
        Returns:
        the number of seconds since the object stored at the specified key is idle (not requested by read or write operations). While the value is returned in seconds the actual resolution of this timer is 10 seconds, but may vary in future implementations.
      • pubsub

        public RedisObject pubsub​(String subcommand,
                                  String... arguments)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/pubsub:

        Available since 2.8.0.

        Time complexity: O(N) for the CHANNELS subcommand, where N is the number of active channels, and assuming constant time pattern matching (relatively short channels and patterns). O(N) for the NUMSUB subcommand, where N is the number of requested channels. O(1) for the NUMPAT subcommand.

        The PUBSUB command is an introspection command that allows to inspect the state of the Pub/Sub subsystem.

        This call is here in order to support commands that don't have signatures.

        Specified by:
        pubsub in interface RedisServerCommands
        Parameters:
        subcommand - the pubsub subcommand.
        arguments - the additional arguments.
        Returns:
        the Redis object returned.
      • pubsubChannels

        public String[] pubsubChannels​(String pattern)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/pubsub:

        Available since 2.8.0.

        Time complexity: O(N), where N is the number of active channels, and assuming constant time pattern matching (relatively short channels and patterns).

        The PUBSUB command is an introspection command that allows to inspect the state of the Pub/Sub subsystem.

        Specified by:
        pubsubChannels in interface RedisServerCommands
        Parameters:
        pattern - the pattern to search for.
        Returns:
        a list of active channels, optionally matching the specified pattern.
      • pubsubNumsub

        public String[] pubsubNumsub​(String... arguments)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/pubsub:

        Available since 2.8.0.

        Time complexity: O(N), where N is the number of requested channels.

        The PUBSUB command is an introspection command that allows to inspect the state of the Pub/Sub subsystem.

        Specified by:
        pubsubNumsub in interface RedisServerCommands
        Parameters:
        arguments - the channel names.
        Returns:
        a list of channels and number of subscribers for every channel. The format is channel, count, channel, count, ..., so the list is flat. The order in which the channels are listed is the same as the order of the channels specified in the command call.
      • pubsubNumpat

        public long pubsubNumpat()
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/pubsub:

        Available since 2.8.0.

        Time complexity: O(1) for the NUMPAT subcommand.

        The PUBSUB command is an introspection command that allows to inspect the state of the Pub/Sub subsystem.

        Specified by:
        pubsubNumpat in interface RedisServerCommands
        Returns:
        the number of patterns all the clients are subscribed to.
      • save

        public boolean save()
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/save:

        Available since 1.0.0.

        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.

        Specified by:
        save in interface RedisServerCommands
        Returns:
        always true.
      • slaveof

        public boolean slaveof​(String host,
                               String port)
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/slaveof:

        Available since 1.0.0.

        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 RedisServerCommands.slaveof(String, String) hostname port will make the server a slave of another server listening at the specified hostname and port.

        Specified by:
        slaveof in interface RedisServerCommands
        Parameters:
        host - the hostname.
        port - the port.
        Returns:
        always true.
      • slaveofNoOne

        public boolean slaveofNoOne()
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/slaveof:

        Available since 1.0.0.

        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 RedisServerCommands.slaveof(String, String) hostname port will make the server a slave of another server listening at the specified hostname and port.

        Specified by:
        slaveofNoOne in interface RedisServerCommands
        Returns:
        always true.
      • time

        public long[] time()
        Description copied from interface: RedisServerCommands

        From http://redis.io/commands/time:

        Available since 2.6.0.

        Time complexity: O(1)

        The TIME command returns the current server time as a two items lists: a Unix timestamp and the amount of microseconds already elapsed in the current second. Basically the interface is very similar to the one of the gettimeofday system call.

        Specified by:
        time in interface RedisServerCommands
        Returns:
        UNIX time in seconds, microseconds.