Programmer Reference : Redis : EsRedisKeyCommands
EsRedisKeyCommands
Description
Provides an API for the Redis commands that manage keys in the database, such as setting expirations and deleting keys.
This command group is accessed via EsRedisClient>>keys.
Class Methods
None
Instance Methods
copy:to:
  Copy a key.
    
     Arguments:
        aSourceKey - <String> The source key.
        aDestinationKey - <String> The destination key.
     Answers:
        <Boolean> true if the key was copied, false otherwise.
        <EsFuture> In async mode, a future that completes with the result.
del:
  Delete one or more keys.
     
     Arguments:
        aKeyOrCollection - <String | SequenceableCollection> The key or keys to delete.
     Answers:
        <Integer> The number of keys that were removed.
        <EsFuture> In async mode, a future that completes with the result.
dump:
  Return a serialized version of the value stored at the specified key, 
     in the Redis-specific format for the RESTORE command.
    
    Arguments: 
        aKey - <String> The key to serialize.
    Answers: 
        <ByteArray | String> The serialized value, or nil if the key does not exist.
        <EsFuture> In async mode, a future that completes with the result.
exists:
  Determine if one or more keys exist.
     
     Arguments:
        aKeyOrCollection - <String | SequenceableCollection> The key or keys to check.
     Answers:
        <Integer> The number of keys from the given arguments that exist.
        <EsFuture> In async mode, a future that completes with the result.
expire:seconds:
  Set a key's time to live in seconds.
     
     Arguments:
        aKey - <String> The key to set the expiration on.
        anInteger - <Integer> The time to live in seconds.
     Answers:
        <Boolean> true if the timeout was set, false if the key does not exist.
        <EsFuture> In async mode, a future that completes with the result.
expireat:timestamp:
  Set a key's time to live, specified as a Unix timestamp in seconds.
    
    Arguments: 
        aKey - <String> The key to set the expiration on.
        timestamp - <DateAndTime> Unix timestamp in seconds.
    Answers: 
        <Boolean> true if the timeout was set, false if the key does not exist.
        <EsFuture> In async mode, a future that completes with the result.
expiretime:
  Get the expiration time for a key in seconds.
    
     Arguments:
        aKey - <String> The key to check.
     Answers:
        <Integer> The time to live in seconds, or a negative value if the key does not exist or has no associated expire.
        <EsFuture> In async mode, a future that completes with the result.
keys:
  Find all keys matching the given pattern.
     
     Arguments:
        aPattern - <String> The glob-style pattern (e.g., 'user:*').
     Answers:
        <Array> A list of keys matching the pattern.
        <EsFuture> In async mode, a future that completes with the result.
migrate:port:key:db:timeout:
  Atomically transfer a key from a Redis instance to another one.
    
     Arguments:
        aHost - <String> The destination host.
        aPort - <Integer> The destination port.
        aKey - <String> The key to migrate.
        aDb - <Integer> The destination database.
        aTimeout - <Integer> The timeout for the operation in milliseconds.
     Answers:
        <String> 'OK' on success.
        <EsFuture> In async mode, a future that completes with the result.
move:toDb:
  Move a key to another Redis database.
    
    Arguments: 
        aKey - <String> The key to move.
        dbIndex - <Integer> The destination database index.
    Answers: 
        <Boolean> true if the key was moved, false if the key was not moved.
        <EsFuture> In async mode, a future that completes with the result.
object:key:
  Inspect the internals of Redis objects associated with keys.
    
    Arguments: 
        subcommand - <String> One of 'REFCOUNT', 'ENCODING', 'IDLETIME', or 'FREQ'.
        aKey - <String> The key to inspect.
    Answers: 
        <Object> The result depends on the subcommand.
        <EsFuture> In async mode, a future that completes with the result.
persist:
  Remove the expiration from a key, making it persistent.
     
     Arguments:
        aKey - <String> The key to make persistent.
     Answers:
        <Boolean> true if the timeout was removed, false if the key does not exist or does not have an associated timeout.
        <EsFuture> In async mode, a future that completes with the result.
pexpire:milliseconds:
  Set a key's time to live in milliseconds.
    
    Arguments: 
        aKey - <String> The key to set the expiration on.
        ms - <Integer> The time to live in milliseconds.
    Answers: 
        <Boolean> true if the timeout was set, false if the key does not exist.
        <EsFuture> In async mode, a future that completes with the result.
pexpireat:msTimestamp:
  Set a key's time to live, specified as a Unix timestamp in milliseconds.
    
    Arguments: 
        aKey - <String> The key to set the expiration on.
        ms - <Integer> Unix timestamp in milliseconds.
    Answers: 
        <Boolean> true if the timeout was set, false if the key does not exist.
        <EsFuture> In async mode, a future that completes with the result.
pexpiretime:
  Get the expiration time for a key in milliseconds.
    
     Arguments:
        aKey - <String> The key to check.
     Answers:
        <Integer> The time to live in milliseconds, or a negative value if the key does not exist or has no associated expire.
        <EsFuture> In async mode, a future that completes with the result.
pttl:
  Get the time to live for a key in milliseconds.
    
    Arguments: 
        aKey - <String> The key to check.
    Answers: 
        <Integer> The time to live in milliseconds, -1 if the key exists but has 
        no associated expire, or -2 if the key does not exist.
        <EsFuture> In async mode, a future that completes with the result.
randomkey
  Return a random key from the currently selected database.
    
    Arguments: 
        None.
    Answers: 
        <String> The name of a random key, or nil if the database is empty.
        <EsFuture> In async mode, a future that completes with the result.
rename:to:
  Rename a key.
     
     Arguments:
        aKey - <String> The current key name.
        aNewKey - <String> The new key name.
     Answers:
        <String> 'OK'.
        <EsFuture> In async mode, a future that completes with the result.
     Raises:
        <EsRedisException> If the old key does not exist.
renamenx:to:
  Rename a key, only if the new key does not exist.
    
    Arguments: 
        aKey - <String> The current key name.
        aNewKey - <String> The new key name.
    Answers: 
        <Boolean> true if the key was renamed, false if the new key already exists.
        <EsFuture> In async mode, a future that completes with the result.
restore:ttl:value:
  Create a key using a serialized value, previously obtained using DUMP.
    
    Arguments: 
        aKey - <String> The key to create.
        ms - <Integer> The TTL (time to live) in milliseconds. 0 means no TTL.
        serialized - <ByteArray | String> The serialized value.
    Answers: 
        <String> 'OK' if successful.
        <EsFuture> In async mode, a future that completes with the result.
scan:args:
  Incrementally iterate the keys in the database.
    
    Arguments: 
        cursor - <Integer | String> The cursor position to start from (use '0' for 
        the initial call).
        args - <Collection> Optional arguments such as MATCH or COUNT.
    Answers: 
        <Array> An array where the first element is the new cursor, and the second 
        is an array of keys.
        <EsFuture> In async mode, a future that completes with the result.
sort:args:
  Sort the elements in a list, set, or sorted set.
    
    Arguments: 
        aKey - <String> The key to sort.
        args - <Collection> Additional arguments such as BY, LIMIT, GET, ASC, DESC, 
        ALPHA, STORE.
    Answers: 
        <Array | Integer> The sorted elements, or the number of elements stored if 
        STORE is specified.
        <EsFuture> In async mode, a future that completes with the result.
sortRo:args:
  Sort the elements in a list, set, or sorted set, without modifying the key.
    
    Arguments:
        aKey - <String> The key to sort.
        args - <Collection> Additional arguments such as BY, LIMIT, GET, ASC, DESC,
        ALPHA.
    Answers:
        <Array | Integer> The sorted elements.
        <EsFuture> In async mode, a future that completes with the result.
touch:
  Alters the last access time of a key(s) without modifying the value.
    
    Arguments: 
        aKeyOrCollection - <String | SequenceableCollection> The key or keys to touch.
    Answers: 
        <Integer> The number of keys that were touched.
        <EsFuture> In async mode, a future that completes with the result.
ttl:
  Get the time to live for a key in seconds.
     
     Arguments:
        aKey - <String> The key to check.
     Answers:
        <Integer> The time to live in seconds, -1 if the key exists but has no associated expire, or -2 if the key does not exist.
        <EsFuture> In async mode, a future that completes with the result.
type:
  Determine the type of value stored at a key.
     
     Arguments:
        aKey - <String> The key to check.
     Answers:
        <String> The type of the key (e.g., 'string', 'list', 'hash'), or 'none' if the key does not exist.
        <EsFuture> In async mode, a future that completes with the result.
unlink:
  Delete one or more keys in a non-blocking manner.
    
    Arguments: 
        aKeyOrCollection - <String | SequenceableCollection> The key or keys to delete.
    Answers: 
        <Integer> The number of keys that were unlinked.
        <EsFuture> In async mode, a future that completes with the result.
wait:timeout:
  Blocks until all the previous write commands are successfully transferred and 
     acknowledged by at least the specified number of replicas.
    
    Arguments: 
        numSlaves - <Integer> Number of replicas to wait for.
        timeout - <Integer> Timeout in milliseconds.
    Answers: 
        <Integer> The number of replicas that acknowledged the write.
        <EsFuture> In async mode, a future that completes with the result.
Last modified date: 01/22/2026