scredis.commands

KeysCommands

trait KeysCommands extends AnyRef

This trait implements keys commands.

Self Type
KeysCommands with Protocol
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. KeysCommands
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. def del(key: String, keys: String*)(implicit opts: CommandOptions = DefaultCommandOptions): Long

    Deletes one or multiple keys.

    Deletes one or multiple keys.

    key

    key to delete

    keys

    additional keys to delete

    returns

    the number of keys that were deleted

    Since

    1.0.0

    Note

    a key is ignored if it does not exist

  7. def dump(key: String)(implicit opts: CommandOptions = DefaultCommandOptions): Option[Array[Byte]]

    Returns a serialized version of the value stored at the specified key.

    Returns a serialized version of the value stored at the specified key.

    key

    key to dump

    returns

    the serialized value or None if the key does not exist

    Since

    2.6.0

  8. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. def exists(key: String)(implicit opts: CommandOptions = DefaultCommandOptions): Boolean

    Determines if a key exists.

    Determines if a key exists.

    key

    key to check for existence

    returns

    true if the key exists, false otherwise

    Since

    1.0.0

  11. def expire(key: String, ttlSeconds: Int)(implicit opts: CommandOptions = DefaultCommandOptions): Boolean

    Sets a key's time to live in seconds.

    Sets a key's time to live in seconds.

    key

    key to expire

    ttlSeconds

    time-to-live in seconds

    returns

    true if the ttl was set, false if key does not exist or the timeout could not be set

    Since

    1.0.0

  12. def expireAt(key: String, timestamp: Long)(implicit opts: CommandOptions = DefaultCommandOptions): Boolean

    Sets the expiration for a key as a UNIX timestamp.

    Sets the expiration for a key as a UNIX timestamp.

    key

    key to expire

    timestamp

    UNIX timestamp at which the key should expire

    returns

    true if the ttl was set, false if key does not exist or the timeout could not be set

    Since

    1.2.0

  13. def expireFromDuration(key: String, ttl: FiniteDuration)(implicit opts: CommandOptions = DefaultCommandOptions): Boolean

    Sets a key's time to live.

    Sets a key's time to live.

    key

    key to expire

    ttl

    duration after which the key should expire, up to milliseconds precision

    returns

    true if the ttl was set, false if key does not exist or the timeout could not be set

    Since

    2.6.0

  14. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. def generateSortCommand(key: String, by: Option[String], limit: Option[(Long, Long)], get: Traversable[String], desc: Boolean, alpha: Boolean): ListBuffer[Any]

    Attributes
    protected
  16. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  17. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  19. def keys(pattern: String)(implicit opts: CommandOptions = DefaultCommandOptions): Set[String]

    Finds all keys matching the given pattern.

    Finds all keys matching the given pattern.

    pattern

    pattern to search for

    returns

    the matched keys, or the empty set if no keys match the given pattern

    Since

    1.0.0

  20. def migrate(key: String, host: String, port: Int = 6379, database: Int = 0, timeout: FiniteDuration = ..., copy: Boolean = false, replace: Boolean = false)(implicit opts: CommandOptions = DefaultCommandOptions): Unit

    Atomically transfers a key from a Redis instance to another one.

    Atomically transfers a key from a Redis instance to another one.

    key

    key to transfer

    host

    destination host

    port

    destination port

    database

    destination database

    timeout

    timeout duration, up to milliseconds precision

    copy

    if true, do not remove the key from the local instance

    replace

    if true, replace existing key on the remote instance

    Since

    2.6.0

    Exceptions thrown
    [[scredis.exceptions.RedisCommandException]]

    if an error occurs

  21. def move(key: String, database: Int)(implicit opts: CommandOptions = DefaultCommandOptions): Boolean

    Moves a key to another database.

    Moves a key to another database.

    key

    key to move

    database

    destination database

    returns

    true if key was moved, false otherwise

    Since

    1.0.0

  22. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  23. final def notify(): Unit

    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  25. def pExpire(key: String, ttlMillis: Long)(implicit opts: CommandOptions = DefaultCommandOptions): Boolean

    Sets a key's time to live in milliseconds.

    Sets a key's time to live in milliseconds.

    key

    key to expire

    ttlMillis

    time-to-live in milliseconds

    returns

    true if the ttl was set, false if key does not exist or the timeout could not be set

    Since

    2.6.0

  26. def pExpireAt(key: String, timestampMillis: Long)(implicit opts: CommandOptions = DefaultCommandOptions): Boolean

    Sets the expiration for a key as a UNIX timestamp specified in milliseconds.

    Sets the expiration for a key as a UNIX timestamp specified in milliseconds.

    key

    key to expire

    timestampMillis

    UNIX milliseconds-timestamp at which the key should expire

    returns

    true if the ttl was set, false if key does not exist or the timeout could not be set

    Since

    2.6.0

  27. def pTtl(key: String)(implicit opts: CommandOptions = DefaultCommandOptions): Either[Boolean, Long]

    Gets the time to live for a key in milliseconds.

    Gets the time to live for a key in milliseconds.

    result match {
    case Left(false) => // key does not exist
    case Left(true) => // key exists but has no associated expire
    case Right(ttl) =>
    }
    key

    the target key

    returns

    Right(ttl) where ttl is the time-to-live in milliseconds for specified key, Left(false) if key does not exist or Left(true) if key exists but has no associated expire

    Since

    2.6.0

    Note

    For Redis version <= 2.8.x, Left(false) will be returned when the key does not exists and when it exists but has no associated expire (Redis returns the same error code for both cases). In other words, you can simply check the following

    result match {
    case Left(_) =>
    case Right(ttl) =>
    }
  28. def persist(key: String)(implicit opts: CommandOptions = DefaultCommandOptions): Boolean

    Removes the expiration from a key.

    Removes the expiration from a key.

    key

    key to persist

    returns

    true if key was persisted, false if key does not exist or does not have an associated timeout

    Since

    2.2.0

  29. def randomKey()(implicit opts: CommandOptions = DefaultCommandOptions): Option[String]

    Returns a random key from the keyspace.

    Returns a random key from the keyspace.

    returns

    the random key or None when the database is empty associated timeout

    Since

    1.0.0

  30. def rename(key: String, newKey: String)(implicit opts: CommandOptions = DefaultCommandOptions): Unit

    Renames a key.

    Renames a key.

    key

    source key

    newKey

    destination key

    Since

    1.0.0

    Exceptions thrown
    [[scredis.exceptions.RedisCommandException]]

    if the source and destination keys are the same, or when key does not exist

    Note

    if newKey already exists, it is overwritten

  31. def renameNX(key: String, newKey: String)(implicit opts: CommandOptions = DefaultCommandOptions): Boolean

    Renames a key, only if the new key does not exist.

    Renames a key, only if the new key does not exist.

    key

    source key

    newKey

    destination key

    returns

    true if key was renamed to newKey, false if newKey already exists

    Since

    1.0.0

    Exceptions thrown
    [[scredis.exceptions.RedisCommandException]]

    if the source and destination keys are the same, or when key does not exist

  32. def restore(key: String, serializedValue: Array[Byte], ttl: Option[FiniteDuration] = None)(implicit opts: CommandOptions = DefaultCommandOptions): Unit

    Creates a key using the provided serialized value, previously obtained using DUMP.

    Creates a key using the provided serialized value, previously obtained using DUMP.

    key

    destination key

    serializedValue

    serialized value, previously obtained using DUMP

    ttl

    optional time-to-live duration of newly created key (expire)

    Since

    2.6.0

    Exceptions thrown
    [[scredis.exceptions.RedisCommandException]]

    if the value could not be restored

  33. def scan[A](cursor: Long, countOpt: Option[Int] = None, matchOpt: Option[String] = None)(implicit opts: CommandOptions = DefaultCommandOptions, parser: Parser[A] = StringParser): (Long, Set[A])

    Incrementally iterates the set of keys in the currently selected Redis database.

    Incrementally iterates the set of keys in the currently selected Redis database.

    cursor

    the offset

    countOpt

    when defined, provides a hint of how many elements should be returned

    matchOpt

    when defined, the command only returns elements matching the pattern

    returns

    a pair containing the next cursor as its first element and the set of keys as its second element

    Since

    2.8.0

  34. def sort[A](key: String, by: Option[String] = None, limit: Option[(Long, Long)] = None, get: Traversable[String] = Traversable(), desc: Boolean = false, alpha: Boolean = false)(implicit opts: CommandOptions = DefaultCommandOptions, parser: Parser[A] = StringParser): List[Option[A]]

    Sorts the elements of a list, set or sorted set.

    Sorts the elements of a list, set or sorted set.

    key

    key of list, set or sorted set to be sorted

    by

    optional pattern for sorting by external values, can also be "nosort" if the sorting operation should be skipped (useful when only sorting to retrieve objects with get). The * gets replaced by the values of the elements in the collection

    limit

    optional pair of numbers (offset, count) where offset specified the number of elements to skip and count specifies the number of elements to return starting from offset

    get

    list of patterns for retrieving objects stored in external keys. The * gets replaced by the values of the elements in the collection

    desc

    indicates whether elements should be sorted descendingly

    alpha

    indicates whether elements should be sorted lexicographically

    returns

    the sorted list of elements, or the empty list if the key does not exist

    Since

    1.0.0

    Exceptions thrown
    [[scredis.exceptions.RedisCommandException]]

    whenever an error occurs

  35. def sortAndStore(key: String, targetKey: String, by: Option[String] = None, limit: Option[(Long, Long)] = None, get: Traversable[String] = Traversable(), desc: Boolean = false, alpha: Boolean = false)(implicit opts: CommandOptions = DefaultCommandOptions): Long

    Sorts the elements of a list, set or sorted set and then store the result.

    Sorts the elements of a list, set or sorted set and then store the result.

    key

    key of list, set or sorted set to be sorted

    targetKey

    key of list, set or sorted set to be sorted

    by

    optional pattern for sorting by external values, can also be "nosort" if the sorting operation should be skipped (useful when only sorting to retrieve objects with get). The * gets replaced by the values of the elements in the collection

    limit

    optional pair of numbers (offset, count) where offset specified the number of elements to skip and count specifies the number of elements to return starting from offset

    get

    list of patterns for retrieving objects stored in external keys. The * gets replaced by the values of the elements in the collection

    desc

    indicates whether elements should be sorted descendingly

    alpha

    indicates whether elements should be sorted lexicographically

    returns

    the number of elements in the newly stored sorted collection

    Since

    1.0.0

    Exceptions thrown
    [[scredis.exceptions.RedisCommandException]]

    whenever an error occurs

  36. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  37. def toString(): String

    Definition Classes
    AnyRef → Any
  38. def ttl(key: String)(implicit opts: CommandOptions = DefaultCommandOptions): Either[Boolean, Int]

    Gets the time to live for a key in seconds.

    Gets the time to live for a key in seconds.

    result match {
    case Left(false) => // key does not exist
    case Left(true) => // key exists but has no associated expire
    case Right(ttl) =>
    }
    key

    the target key

    returns

    Right(ttl) where ttl is the time-to-live in seconds for specified key, Left(false) if key does not exist or Left(true) if key exists but has no associated expire

    Since

    1.0.0

    Note

    For Redis version <= 2.8.x, Left(false) will be returned when the key does not exists and when it exists but has no associated expire (Redis returns the same error code for both cases). In other words, you can simply check the following

    result match {
    case Left(_) =>
    case Right(ttl) =>
    }
  39. def ttlDuration(key: String)(implicit opts: CommandOptions = DefaultCommandOptions): Either[Boolean, FiniteDuration]

    Gets the time to live FiniteDuration for a key.

    Gets the time to live FiniteDuration for a key.

    result match {
    case Left(false) => // key does not exist
    case Left(true) => // key exists but has no associated expire
    case Right(ttl) =>
    }
    key

    the target key

    returns

    Right(ttl) where ttl is the time-to-live FiniteDuration for specified key, Left(false) if key does not exist or Left(true) if key exists but has no associated expire

    Since

    2.6.0

    Note

    For Redis version <= 2.8.x, Left(false) will be returned when the key does not exists and when it exists but has no associated expire (Redis returns the same error code for both cases). In other words, you can simply check the following

    result match {
    case Left(_) =>
    case Right(ttl) =>
    }
  40. def type(key: String)(implicit opts: CommandOptions = DefaultCommandOptions): Option[String]

    Determine the type stored at key.

    Determine the type stored at key.

    key

    key for which the type should be returned

    returns

    type of key, or None if key does not exist

    Since

    1.0.0

    Note

    This method needs to be called as follows:

    client.`type`(key)
  41. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  43. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped