Interface RedisKeyCommands<K,​V>

    • Method Detail

      • copy

        Boolean copy​(K source,
                     K destination)
        Copy the value stored at the source key to the destination key.
        Parameters:
        source - the source.
        destination - the destination.
        Returns:
        Boolean integer-reply specifically: true if source was copied. false if source was not copied.
        Since:
        6.1
      • copy

        Boolean copy​(K source,
                     K destination,
                     CopyArgs copyArgs)
        Copy the value stored at the source key to the destination key.
        Parameters:
        source - the source.
        destination - the destination.
        copyArgs - the copyArgs.
        Returns:
        Boolean integer-reply specifically: true if source was copied. false if source was not copied.
        Since:
        6.1
      • del

        Long del​(K... keys)
        Delete one or more keys.
        Parameters:
        keys - the keys.
        Returns:
        Long integer-reply The number of keys that were removed.
      • unlink

        Long unlink​(K... keys)
        Unlink one or more keys (non blocking DEL).
        Parameters:
        keys - the keys.
        Returns:
        Long integer-reply The number of keys that were removed.
      • dump

        byte[] dump​(K key)
        Return a serialized version of the value stored at the specified key.
        Parameters:
        key - the key.
        Returns:
        byte[] bulk-string-reply the serialized value.
      • exists

        Long exists​(K... keys)
        Determine how many keys exist.
        Parameters:
        keys - the keys.
        Returns:
        Long integer-reply specifically: Number of existing keys.
      • expire

        Boolean expire​(K key,
                       long seconds)
        Set a key's time to live in seconds.
        Parameters:
        key - the key.
        seconds - the seconds type: long.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set.
      • expire

        Boolean expire​(K key,
                       long seconds,
                       ExpireArgs expireArgs)
        Set a key's time to live in seconds.
        Parameters:
        key - the key.
        seconds - the seconds type: long.
        expireArgs - the expire arguments.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set.
        Since:
        6.2
      • expire

        Boolean expire​(K key,
                       Duration seconds)
        Set a key's time to live in seconds.
        Parameters:
        key - the key.
        seconds - the seconds.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set.
        Since:
        6.1
      • expire

        Boolean expire​(K key,
                       Duration seconds,
                       ExpireArgs expireArgs)
        Set a key's time to live in seconds.
        Parameters:
        key - the key.
        seconds - the seconds.
        expireArgs - the expire arguments.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set.
        Since:
        6.2
      • expireat

        Boolean expireat​(K key,
                         long timestamp)
        Set the expiration for a key as a UNIX timestamp.
        Parameters:
        key - the key.
        timestamp - the timestamp type: posix time.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
      • expireat

        Boolean expireat​(K key,
                         long timestamp,
                         ExpireArgs expireArgs)
        Set the expiration for a key as a UNIX timestamp.
        Parameters:
        key - the key.
        timestamp - the timestamp type: posix time.
        expireArgs - the expire arguments.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
        Since:
        6.2
      • expireat

        Boolean expireat​(K key,
                         Date timestamp)
        Set the expiration for a key as a UNIX timestamp.
        Parameters:
        key - the key.
        timestamp - the timestamp type: posix time.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
      • expireat

        Boolean expireat​(K key,
                         Date timestamp,
                         ExpireArgs expireArgs)
        Set the expiration for a key as a UNIX timestamp.
        Parameters:
        key - the key.
        timestamp - the timestamp type: posix time.
        expireArgs - the expire arguments.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
        Since:
        6.2
      • expireat

        Boolean expireat​(K key,
                         Instant timestamp)
        Set the expiration for a key as a UNIX timestamp.
        Parameters:
        key - the key.
        timestamp - the timestamp type: posix time.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
        Since:
        6.1
      • expireat

        Boolean expireat​(K key,
                         Instant timestamp,
                         ExpireArgs expireArgs)
        Set the expiration for a key as a UNIX timestamp.
        Parameters:
        key - the key.
        timestamp - the timestamp type: posix time.
        expireArgs - the expire arguments.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
        Since:
        6.2
      • expiretime

        Long expiretime​(K key)
        Get the time to live for a key in as unix timestamp in seconds.
        Parameters:
        key - the key.
        Returns:
        Long integer-reply in seconds, or a negative value in order to signal an error. The command returns -1 if the key exists but has no associated expiration time. The command returns -2 if the key does not exist.
        Since:
        6.2
      • keys

        List<K> keys​(K pattern)
        Find all keys matching the given pattern.
        Parameters:
        pattern - the pattern type: patternkey (pattern).
        Returns:
        List<K> array-reply list of keys matching pattern.
      • keys

        Long keys​(KeyStreamingChannel<K> channel,
                  K pattern)
        Find all keys matching the given pattern.
        Parameters:
        channel - the channel.
        pattern - the pattern.
        Returns:
        Long array-reply list of keys matching pattern.
      • migrate

        String migrate​(String host,
                       int port,
                       K key,
                       int db,
                       long timeout)
        Atomically transfer a key from a Redis instance to another one.
        Parameters:
        host - the host.
        port - the port.
        key - the key.
        db - the database.
        timeout - the timeout in milliseconds.
        Returns:
        String simple-string-reply The command returns OK on success.
      • migrate

        String migrate​(String host,
                       int port,
                       int db,
                       long timeout,
                       MigrateArgs<K> migrateArgs)
        Atomically transfer one or more keys from a Redis instance to another one.
        Parameters:
        host - the host.
        port - the port.
        db - the database.
        timeout - the timeout in milliseconds.
        migrateArgs - migrate args that allow to configure further options.
        Returns:
        String simple-string-reply The command returns OK on success.
      • move

        Boolean move​(K key,
                     int db)
        Move a key to another database.
        Parameters:
        key - the key.
        db - the db type: long.
        Returns:
        Boolean integer-reply specifically:.
      • objectEncoding

        String objectEncoding​(K key)
        Returns the kind of internal representation used in order to store the value associated with the key.
        Parameters:
        key - the key.
        Returns:
        String.
      • objectFreq

        Long objectFreq​(K key)
        Returns the logarithmic access frequency counter of the object stored at the specified key.
        Parameters:
        key - the key.
        Returns:
        Long.
        Since:
        6.1
      • objectIdletime

        Long objectIdletime​(K key)
        Returns the number of seconds since the object stored at the specified key is idle (not requested by read or write operations).
        Parameters:
        key - the key.
        Returns:
        number of seconds since the object stored at the specified key is idle.
      • objectRefcount

        Long objectRefcount​(K key)
        Returns the number of references of the value associated with the specified key.
        Parameters:
        key - the key.
        Returns:
        Long.
      • persist

        Boolean persist​(K key)
        Remove the expiration from a key.
        Parameters:
        key - the key.
        Returns:
        Boolean integer-reply specifically: true if the timeout was removed. false if key does not exist or does not have an associated timeout.
      • pexpire

        Boolean pexpire​(K key,
                        long milliseconds)
        Set a key's time to live in milliseconds.
        Parameters:
        key - the key.
        milliseconds - the milliseconds type: long.
        Returns:
        integer-reply, specifically: true if the timeout was set. false if key does not exist or the timeout could not be set.
      • pexpire

        Boolean pexpire​(K key,
                        long milliseconds,
                        ExpireArgs expireArgs)
        Set a key's time to live in milliseconds.
        Parameters:
        key - the key.
        milliseconds - the milliseconds type: long.
        expireArgs - the expire arguments.
        Returns:
        integer-reply, specifically: true if the timeout was set. false if key does not exist or the timeout could not be set.
        Since:
        6.2
      • pexpire

        Boolean pexpire​(K key,
                        Duration milliseconds)
        Set a key's time to live in milliseconds.
        Parameters:
        key - the key.
        milliseconds - the milliseconds.
        Returns:
        integer-reply, specifically: true if the timeout was set. false if key does not exist or the timeout could not be set.
        Since:
        6.1
      • pexpire

        Boolean pexpire​(K key,
                        Duration milliseconds,
                        ExpireArgs expireArgs)
        Set a key's time to live in milliseconds.
        Parameters:
        key - the key.
        milliseconds - the milliseconds.
        expireArgs - the expire arguments.
        Returns:
        integer-reply, specifically: true if the timeout was set. false if key does not exist or the timeout could not be set.
        Since:
        6.2
      • pexpireat

        Boolean pexpireat​(K key,
                          long timestamp)
        Set the expiration for a key as a UNIX timestamp specified in milliseconds.
        Parameters:
        key - the key.
        timestamp - the milliseconds-timestamp type: posix time.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
      • pexpireat

        Boolean pexpireat​(K key,
                          long timestamp,
                          ExpireArgs expireArgs)
        Set the expiration for a key as a UNIX timestamp specified in milliseconds.
        Parameters:
        key - the key.
        timestamp - the milliseconds-timestamp type: posix time.
        expireArgs - the expire arguments.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
        Since:
        6.2
      • pexpireat

        Boolean pexpireat​(K key,
                          Date timestamp)
        Set the expiration for a key as a UNIX timestamp specified in milliseconds.
        Parameters:
        key - the key.
        timestamp - the milliseconds-timestamp type: posix time.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
      • pexpireat

        Boolean pexpireat​(K key,
                          Date timestamp,
                          ExpireArgs expireArgs)
        Set the expiration for a key as a UNIX timestamp specified in milliseconds.
        Parameters:
        key - the key.
        timestamp - the milliseconds-timestamp type: posix time.
        expireArgs - the expire arguments.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
        Since:
        6.2
      • pexpireat

        Boolean pexpireat​(K key,
                          Instant timestamp)
        Set the expiration for a key as a UNIX timestamp specified in milliseconds.
        Parameters:
        key - the key.
        timestamp - the milliseconds-timestamp type: posix time.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
      • pexpireat

        Boolean pexpireat​(K key,
                          Instant timestamp,
                          ExpireArgs expireArgs)
        Set the expiration for a key as a UNIX timestamp specified in milliseconds.
        Parameters:
        key - the key.
        timestamp - the milliseconds-timestamp type: posix time.
        expireArgs - the expire arguments.
        Returns:
        Boolean integer-reply specifically: true if the timeout was set. false if key does not exist or the timeout could not be set (see: EXPIRE).
        Since:
        6.2
      • pexpiretime

        Long pexpiretime​(K key)
        Get the time to live for a key in as unix timestamp in milliseconds.
        Parameters:
        key - the key.
        Returns:
        Long integer-reply in milliseconds, or a negative value in order to signal an error. The command returns -1 if the key exists but has no associated expiration time. The command returns -2 if the key does not exist.
        Since:
        6.2
      • pttl

        Long pttl​(K key)
        Get the time to live for a key in milliseconds.
        Parameters:
        key - the key.
        Returns:
        Long integer-reply in milliseconds, or a negative value in order to signal an error. The command returns -1 if the key exists but has no associated expiration time. The command returns -2 if the key does not exist.
      • randomkey

        K randomkey()
        Return a random key from the keyspace.
        Returns:
        K bulk-string-reply the random key, or null when the database is empty.
      • rename

        String rename​(K key,
                      K newKey)
        Rename a key.
        Parameters:
        key - the key.
        newKey - the newkey type: key.
        Returns:
        String simple-string-reply.
      • renamenx

        Boolean renamenx​(K key,
                         K newKey)
        Rename a key, only if the new key does not exist.
        Parameters:
        key - the key.
        newKey - the newkey type: key.
        Returns:
        Boolean integer-reply specifically: true if key was renamed to newkey. false if newkey already exists.
      • restore

        String restore​(K key,
                       long ttl,
                       byte[] value)
        Create a key using the provided serialized value, previously obtained using DUMP.
        Parameters:
        key - the key.
        ttl - the ttl type: long.
        value - the serialized-value type: string.
        Returns:
        String simple-string-reply The command returns OK on success.
      • restore

        String restore​(K key,
                       byte[] value,
                       RestoreArgs args)
        Create a key using the provided serialized value, previously obtained using DUMP.
        Parameters:
        key - the key.
        value - the serialized-value type: string.
        args - the RestoreArgs, must not be null.
        Returns:
        String simple-string-reply The command returns OK on success.
        Since:
        5.1
      • sort

        List<V> sort​(K key)
        Sort the elements in a list, set or sorted set.
        Parameters:
        key - the key.
        Returns:
        List<V> array-reply list of sorted elements.
      • sort

        Long sort​(ValueStreamingChannel<V> channel,
                  K key)
        Sort the elements in a list, set or sorted set.
        Parameters:
        channel - streaming channel that receives a call for every value.
        key - the key.
        Returns:
        Long number of values.
      • sort

        List<V> sort​(K key,
                     SortArgs sortArgs)
        Sort the elements in a list, set or sorted set.
        Parameters:
        key - the key.
        sortArgs - sort arguments.
        Returns:
        List<V> array-reply list of sorted elements.
      • sort

        Long sort​(ValueStreamingChannel<V> channel,
                  K key,
                  SortArgs sortArgs)
        Sort the elements in a list, set or sorted set.
        Parameters:
        channel - streaming channel that receives a call for every value.
        key - the key.
        sortArgs - sort arguments.
        Returns:
        Long number of values.
      • sortReadOnly

        List<V> sortReadOnly​(K key)
        Sort the elements in a list, set or sorted set.
        Parameters:
        key - the key.
        Returns:
        List<V> array-reply list of sorted elements.
        Since:
        6.2
      • sortReadOnly

        Long sortReadOnly​(ValueStreamingChannel<V> channel,
                          K key)
        Sort the elements in a list, set or sorted set.
        Parameters:
        channel - streaming channel that receives a call for every value.
        key - the key.
        Returns:
        Long number of values.
        Since:
        6.2
      • sortReadOnly

        List<V> sortReadOnly​(K key,
                             SortArgs sortArgs)
        Sort the elements in a list, set or sorted set.
        Parameters:
        key - the key.
        sortArgs - sort arguments.
        Returns:
        List<V> array-reply list of sorted elements.
        Since:
        6.2
      • sortReadOnly

        Long sortReadOnly​(ValueStreamingChannel<V> channel,
                          K key,
                          SortArgs sortArgs)
        Sort the elements in a list, set or sorted set.
        Parameters:
        channel - streaming channel that receives a call for every value.
        key - the key.
        sortArgs - sort arguments.
        Returns:
        Long number of values.
        Since:
        6.2
      • sortStore

        Long sortStore​(K key,
                       SortArgs sortArgs,
                       K destination)
        Sort the elements in a list, set or sorted set.
        Parameters:
        key - the key.
        sortArgs - sort arguments.
        destination - the destination key to store sort results.
        Returns:
        Long number of values.
      • touch

        Long touch​(K... keys)
        Touch one or more keys. Touch sets the last accessed time for a key. Non-exsitent keys wont get created.
        Parameters:
        keys - the keys.
        Returns:
        Long integer-reply the number of found keys.
      • ttl

        Long ttl​(K key)
        Get the time to live for a key.
        Parameters:
        key - the key.
        Returns:
        Long integer-reply TTL in seconds, or a negative value in order to signal an error. The command returns -1 if the key exists but has no associated expiration time. The command returns -2 if the key does not exist.
      • type

        String type​(K key)
        Determine the type stored at key.
        Parameters:
        key - the key.
        Returns:
        String simple-string-reply type of key, or none when key does not exist.
      • scan

        KeyScanCursor<K> scan()
        Incrementally iterate the keys space.
        Returns:
        KeyScanCursor<K> scan cursor.
      • scan

        KeyScanCursor<K> scan​(ScanArgs scanArgs)
        Incrementally iterate the keys space. Use KeyScanArgs to specify SCAN-specific arguments.
        Parameters:
        scanArgs - scan arguments.
        Returns:
        KeyScanCursor<K> scan cursor.
        See Also:
        KeyScanArgs
      • scan

        KeyScanCursor<K> scan​(ScanCursor scanCursor,
                              ScanArgs scanArgs)
        Incrementally iterate the keys space. Use KeyScanArgs to specify SCAN-specific arguments.
        Parameters:
        scanCursor - cursor to resume from a previous scan, must not be null.
        scanArgs - scan arguments.
        Returns:
        KeyScanCursor<K> scan cursor.
        See Also:
        KeyScanArgs
      • scan

        KeyScanCursor<K> scan​(ScanCursor scanCursor)
        Incrementally iterate the keys space.
        Parameters:
        scanCursor - cursor to resume from a previous scan, must not be null.
        Returns:
        KeyScanCursor<K> scan cursor.
      • scan

        StreamScanCursor scan​(KeyStreamingChannel<K> channel)
        Incrementally iterate the keys space.
        Parameters:
        channel - streaming channel that receives a call for every key.
        Returns:
        StreamScanCursor scan cursor.
      • scan

        StreamScanCursor scan​(KeyStreamingChannel<K> channel,
                              ScanArgs scanArgs)
        Incrementally iterate the keys space. Use KeyScanArgs to specify SCAN-specific arguments.
        Parameters:
        channel - streaming channel that receives a call for every key.
        scanArgs - scan arguments.
        Returns:
        StreamScanCursor scan cursor.
        See Also:
        KeyScanArgs
      • scan

        StreamScanCursor scan​(KeyStreamingChannel<K> channel,
                              ScanCursor scanCursor,
                              ScanArgs scanArgs)
        Incrementally iterate the keys space. Use KeyScanArgs to specify SCAN-specific arguments.
        Parameters:
        channel - streaming channel that receives a call for every key.
        scanCursor - cursor to resume from a previous scan, must not be null.
        scanArgs - scan arguments.
        Returns:
        StreamScanCursor scan cursor.
        See Also:
        KeyScanArgs
      • scan

        StreamScanCursor scan​(KeyStreamingChannel<K> channel,
                              ScanCursor scanCursor)
        Incrementally iterate the keys space.
        Parameters:
        channel - streaming channel that receives a call for every key.
        scanCursor - cursor to resume from a previous scan, must not be null.
        Returns:
        StreamScanCursor scan cursor.