Interface RKeys

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean  name)
      Clear an expire timeout or expire date for object.
      void  name,  host, int port, int database, long timeout)
      Copy object from source Redis instance to destination Redis instance
      long count()
      Returns the number of keys in the currently-selected database
      long ... names)
      Checks if provided keys exist
      long ... keys)
      Delete multiple objects by name
      long delete​(RObject... objects)
      Delete multiple objects
      long  pattern)
      Delete multiple objects by a key pattern.
      boolean  name, long timeToLive,  timeUnit)
      Set a timeout for object.
      boolean  name, long timestamp)
      Set an expire date for object.
      void flushall()
      Delete all keys of all existing databases
      void flushallParallel()
      Delete all keys of all existing databases in background without blocking server.
      void flushdb()
      Delete all keys of currently selected database
      void flushdbParallel()
      Delete all keys of currently selected database in background without blocking server.
      <> getKeys()
      Get all keys using iterator.
      <> getKeys​(int count)
      Get all keys using iterator.
      <>  pattern)
      Get all keys by pattern using iterator.
      <>  pattern, int count)
      Get all keys by pattern using iterator.
      <> getKeysStream()
      Get all keys using Stream.
      <> getKeysStream​(int count)
      Get all keys using Stream.
      <>  pattern)
      Get all keys by pattern using Stream.
      <>  pattern, int count)
      Get all keys by pattern using Stream.
      <> getKeysWithLimit​(int limit)
      Get keys using iterator with defined limit.
      <>  pattern, int limit)
      Get keys using iterator with defined limit.
      int  key)
      Get hash slot identifier for key.
      RType  key)
      Get Redis object type by key
      void  name,  host, int port, int database, long timeout)
      Transfer object from source Redis instance to destination Redis instance
      boolean  name, int database)
      Move object to another database
      randomKey()
      Get random key
      long  name)
      Remaining time to live of Redisson object that has a timeout
      void  currentName,  newName)
      Rename current object key to newName
      boolean  oldName,  newName)
      Rename object with oldName to newName only if new key is not exists
      void swapdb​(int db1, int db2)
      Swap two databases.
      long ... names)
      Update the last access time of an object.
      long ... keys)
      Delete multiple objects by name.
    • Method Detail

      • getKeysWithLimit

        <> getKeysWithLimit​(int limit)
        Get keys using iterator with defined limit. Keys are traversed with SCAN operation.
        Parameters:
        limit - - limit of keys amount
        Returns:
        Iterable object
      • getKeysWithLimit

        <> getKeysWithLimit​( pattern,
                                          int limit)
        Get keys using iterator with defined limit. Keys are traversed with SCAN operation.

        Supported glob-style patterns:

        h?llo subscribes to hello, hallo and hxllo

        h*llo subscribes to hllo and heeeello

        h[ae]llo subscribes to hello and hallo, but not hillo

        Parameters:
        limit - - limit of keys amount
        pattern - - match pattern
        Returns:
        Iterable object
      • move

        boolean move​( name,
                     int database)
        Move object to another database
        Parameters:
        name - of object
        database - - Redis database number
        Returns:
        true if key was moved else false
      • migrate

        void migrate​( name,
                      host,
                     int port,
                     int database,
                     long timeout)
        Transfer object from source Redis instance to destination Redis instance
        Parameters:
        name - of object
        host - - destination host
        port - - destination port
        database - - destination database
        timeout - - maximum idle time in any moment of the communication with the destination instance in milliseconds
      • copy

        void copy​( name,
                   host,
                  int port,
                  int database,
                  long timeout)
        Copy object from source Redis instance to destination Redis instance
        Parameters:
        name - of object
        host - - destination host
        port - - destination port
        database - - destination database
        timeout - - maximum idle time in any moment of the communication with the destination instance in milliseconds
      • expire

        boolean expire​( name,
                       long timeToLive,
                        timeUnit)
        Set a timeout for object. After the timeout has expired, the key will automatically be deleted.
        Parameters:
        name - of object
        timeToLive - - timeout before object will be deleted
        timeUnit - - timeout time unit
        Returns:
        true if the timeout was set and false if not
      • expireAt

        boolean expireAt​( name,
                         long timestamp)
        Set an expire date for object. When expire date comes the key will automatically be deleted.
        Parameters:
        name - of object
        timestamp - - expire date in milliseconds (Unix timestamp)
        Returns:
        true if the timeout was set and false if not
      • clearExpire

        boolean clearExpire​( name)
        Clear an expire timeout or expire date for object.
        Parameters:
        name - of object
        Returns:
        true if timeout was removed false if object does not exist or does not have an associated timeout
      • renamenx

        boolean renamenx​( oldName,
                          newName)
        Rename object with oldName to newName only if new key is not exists
        Parameters:
        oldName - - old name of object
        newName - - new name of object
        Returns:
        true if object has been renamed successfully and false otherwise
      • rename

        void rename​( currentName,
                     newName)
        Rename current object key to newName
        Parameters:
        currentName - - current name of object
        newName - - new name of object
      • remainTimeToLive

        long remainTimeToLive​( name)
        Remaining time to live of Redisson object that has a timeout
        Parameters:
        name - of key
        Returns:
        time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
      • touch

        long touch​(... names)
        Update the last access time of an object.
        Parameters:
        names - of keys
        Returns:
        count of objects were touched
      • countExists

        long countExists​(... names)
        Checks if provided keys exist
        Parameters:
        names - of keys
        Returns:
        amount of existing keys
      • getType

         key)
        Get Redis object type by key
        Parameters:
        key - - name of key
        Returns:
        type of key
      • getSlot

        int getSlot​( key)
        Get hash slot identifier for key. Available for cluster nodes only
        Parameters:
        key - - name of key
        Returns:
        slot number
      • getKeysByPattern

        <> getKeysByPattern​( pattern)
        Get all keys by pattern using iterator. Keys traversed with SCAN operation. Each SCAN operation loads up to 10 keys per request.

        Supported glob-style patterns:

        h?llo subscribes to hello, hallo and hxllo

        h*llo subscribes to hllo and heeeello

        h[ae]llo subscribes to hello and hallo, but not hillo

        Parameters:
        pattern - - match pattern
        Returns:
        Iterable object
      • getKeysByPattern

        <> getKeysByPattern​( pattern,
                                          int count)
        Get all keys by pattern using iterator. Keys traversed with SCAN operation. Each SCAN operation loads up to count keys per request.

        Supported glob-style patterns:

        h?llo subscribes to hello, hallo and hxllo

        h*llo subscribes to hllo and heeeello

        h[ae]llo subscribes to hello and hallo, but not hillo

        Parameters:
        pattern - - match pattern
        count - - keys loaded per request to Redis
        Returns:
        Iterable object
      • getKeys

        <> getKeys()
        Get all keys using iterator. Keys traversing with SCAN operation. Each SCAN operation loads up to 10 keys per request.
        Returns:
        Iterable object
      • getKeys

        <> getKeys​(int count)
        Get all keys using iterator. Keys traversing with SCAN operation. Each SCAN operation loads up to count keys per request.
        Parameters:
        count - - keys loaded per request to Redis
        Returns:
        Iterable object
      • getKeysStreamByPattern

        <> getKeysStreamByPattern​( pattern)
        Get all keys by pattern using Stream. Keys traversed with SCAN operation. Each SCAN operation loads up to 10 keys per request.

        Supported glob-style patterns:

        h?llo subscribes to hello, hallo and hxllo

        h*llo subscribes to hllo and heeeello

        h[ae]llo subscribes to hello and hallo, but not hillo

        Parameters:
        pattern - - match pattern
        Returns:
        Iterable object
      • getKeysStreamByPattern

        <> getKeysStreamByPattern​( pattern,
                                              int count)
        Get all keys by pattern using Stream. Keys traversed with SCAN operation. Each SCAN operation loads up to count keys per request.

        Supported glob-style patterns:

        h?llo subscribes to hello, hallo and hxllo

        h*llo subscribes to hllo and heeeello

        h[ae]llo subscribes to hello and hallo, but not hillo

        Parameters:
        pattern - - match pattern
        count - - keys loaded per request to Redis
        Returns:
        Iterable object
      • getKeysStream

        <> getKeysStream()
        Get all keys using Stream. Keys traversing with SCAN operation. Each SCAN operation loads up to 10 keys per request.
        Returns:
        Iterable object
      • getKeysStream

        <> getKeysStream​(int count)
        Get all keys using Stream. Keys traversing with SCAN operation. Each SCAN operation loads up to count keys per request.
        Parameters:
        count - - keys loaded per request to Redis
        Returns:
        Iterable object
      • randomKey

         randomKey()
        Get random key
        Returns:
        random key
      • deleteByPattern

        long deleteByPattern​( pattern)
        Delete multiple objects by a key pattern.

        Method executes in NON atomic way in cluster mode due to lua script limitations.

        Supported glob-style patterns: h?llo subscribes to hello, hallo and hxllo h*llo subscribes to hllo and heeeello h[ae]llo subscribes to hello and hallo, but not hillo

        Parameters:
        pattern - - match pattern
        Returns:
        number of removed keys
      • delete

        long delete​(RObject... objects)
        Delete multiple objects
        Parameters:
        objects - of Redisson
        Returns:
        number of removed keys
      • delete

        long delete​(... keys)
        Delete multiple objects by name
        Parameters:
        keys - - object names
        Returns:
        number of removed keys
      • unlink

        long unlink​(... keys)
        Delete multiple objects by name. Actual removal will happen later asynchronously.

        Requires Redis 4.0+

        Parameters:
        keys - of objects
        Returns:
        number of removed keys
      • count

        long count()
        Returns the number of keys in the currently-selected database
        Returns:
        count of keys
      • swapdb

        void swapdb​(int db1,
                    int db2)
        Swap two databases.
      • flushdb

        void flushdb()
        Delete all keys of currently selected database
      • flushdbParallel

        void flushdbParallel()
        Delete all keys of currently selected database in background without blocking server.

        Requires Redis 4.0+

      • flushall

        void flushall()
        Delete all keys of all existing databases
      • flushallParallel

        void flushallParallel()
        Delete all keys of all existing databases in background without blocking server.

        Requires Redis 4.0+