t

scredis.commands

KeyCommands

trait KeyCommands extends AnyRef

This trait implements key commands.

Self Type
KeyCommands with NonBlockingConnection
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. KeyCommands
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

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[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. def del(keys: String*): Future[Long]

    Deletes one or multiple keys.

    Deletes one or multiple keys.

    keys

    key(s) 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): Future[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: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  10. def exists(key: String): Future[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): Future[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): Future[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 finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  14. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. def keys(pattern: String): Future[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

  18. def migrate(key: String, host: String, port: Int = 6379, database: Int = 0, authOpt: Option[AuthConfig] = None, timeout: FiniteDuration = 2.seconds, copy: Boolean = false, replace: Boolean = false): Future[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

    authOpt

    destination server authorization credentials

    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.RedisErrorResponseException]] if an error occurs

  19. def move(key: String, database: Int): Future[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

  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. def objectEncoding(key: String): Future[Option[String]]

    Returns the kind of internal representation used in order to store the value associated with a key.

    Returns the kind of internal representation used in order to store the value associated with a key.

    key

    the key

    returns

    the object encoding or None if the key does not exist

    Since

    2.2.3

    Note

    Objects can be encoded in different ways: Strings can be encoded as raw or int Lists can be encoded as ziplist or linkedlist Sets can be encoded as intset or hashtable Hashes can be encoded as zipmap or hashtable SortedSets can be encoded as ziplist or skiplist

  24. def objectIdleTime(key: String): Future[Option[Long]]

    Returns the number of seconds since the object stored at the specified key is idle (not requested by read or write operations).

    Returns the number of seconds since the object stored at the specified key is idle (not requested by read or write operations).

    key

    the key

    returns

    the number of seconds since the object is idle or None if the key does not exist

    Since

    2.2.3

    Note

    While the value is returned in seconds the actual resolution of this timer is 10 seconds, but may vary in future implementations.

  25. def objectRefCount(key: String): Future[Option[Long]]

    Returns the number of references of the value associated with the specified key.

    Returns the number of references of the value associated with the specified key.

    key

    the key

    returns

    the number of references or None if the key does not exist

    Since

    2.2.3

  26. def pExpire(key: String, ttlMillis: Long): Future[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

  27. def pExpireAt(key: String, timestampMillis: Long): Future[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

  28. def pTtl(key: String): Future[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) =>
    }
  29. def persist(key: String): Future[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

  30. def randomKey(): Future[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

  31. def rename(key: String, newKey: String): Future[Unit]

    Renames a key.

    Renames a key.

    key

    source key

    newKey

    destination key

    Since

    1.0.0

    Exceptions thrown

    [[scredis.exceptions.RedisErrorResponseException]] if the source and destination keys are the same, or when key does not exist

    Note

    if newKey already exists, it is overwritten

  32. def renameNX(key: String, newKey: String): Future[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.RedisErrorResponseException]] if the source and destination keys are the same, or when key does not exist

  33. def restore[W](key: String, serializedValue: W, ttlOpt: Option[FiniteDuration] = None)(implicit arg0: Writer[W]): Future[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

    ttlOpt

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

    Since

    2.6.0

    Exceptions thrown

    [[scredis.exceptions.RedisErrorResponseException]] if the value could not be restored

  34. def scan(cursor: Long, matchOpt: Option[String] = None, countOpt: Option[Int] = None): Future[(Long, Set[String])]

    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

    matchOpt

    when defined, the command only returns elements matching the pattern

    countOpt

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

    returns

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

    Since

    2.8.0

  35. def sort[R](key: String, byOpt: Option[String] = None, limitOpt: Option[(Long, Long)] = None, get: Iterable[String] = Nil, desc: Boolean = false, alpha: Boolean = false)(implicit arg0: Reader[R]): Future[List[Option[R]]]

    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

    byOpt

    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

    limitOpt

    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.RedisErrorResponseException]] whenever an error occurs

  36. def sortAndStore(key: String, targetKey: String, byOpt: Option[String] = None, limitOpt: Option[(Long, Long)] = None, get: Iterable[String] = Nil, desc: Boolean = false, alpha: Boolean = false): Future[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

    byOpt

    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

    limitOpt

    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.RedisErrorResponseException]] whenever an error occurs

  37. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  38. def toString(): String
    Definition Classes
    AnyRef → Any
  39. def ttl(key: String): Future[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) =>
    }
  40. def type(key: String): Future[Option[Type]]

    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(classOf[java.lang.InterruptedException])
  42. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  43. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped