Trait

play.api.cache.redis

CacheApi

Related Doc: package redis

Permalink

trait CacheApi extends AbstractCacheApi[SynchronousResult]

Synchronous and blocking implementation of the connection to the redis database

Linear Supertypes
AbstractCacheApi[SynchronousResult], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CacheApi
  2. AbstractCacheApi
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def append(key: String, value: String, expiration: Duration = Duration.Inf): SynchronousResult[Unit]

    Permalink

    If key already exists and is a string, this command appends the value at the end of the string.

    If key already exists and is a string, this command appends the value at the end of the string. If key does not exist it is created and set as an empty string, so APPEND will be similar to SET in this special case.

    If it sets new value, it subsequently calls EXPIRE to set required expiration time

    key

    cache storage key

    value

    value to append

    expiration

    record duration, applies only when appends to nothing

    returns

    promise

    Definition Classes
    AbstractCacheApi
  2. abstract def decrement(key: String, by: Long = 1): SynchronousResult[Long]

    Permalink

    Decrements the stored string value representing 10-based signed integer by given value.

    Decrements the stored string value representing 10-based signed integer by given value.

    key

    cache storage key

    by

    size of decrement

    returns

    the value after the decrement

    Definition Classes
    AbstractCacheApi
    Since

    1.3.0

  3. abstract def exists(key: String): SynchronousResult[Boolean]

    Permalink

    Determines whether value exists in cache.

    Determines whether value exists in cache.

    key

    cache storage key

    returns

    record existence, true if exists, otherwise false

    Definition Classes
    AbstractCacheApi
  4. abstract def expire(key: String, expiration: Duration): SynchronousResult[Unit]

    Permalink

    refreshes expiration time on a given key, useful, e.g., when we want to refresh session duration

    refreshes expiration time on a given key, useful, e.g., when we want to refresh session duration

    key

    cache storage key

    expiration

    new expiration in seconds

    returns

    promise

    Definition Classes
    AbstractCacheApi
  5. abstract def get[T](key: String)(implicit arg0: ClassTag[T]): SynchronousResult[Option[T]]

    Permalink

    Retrieve a value from the cache.

    Retrieve a value from the cache.

    key

    cache storage key

    returns

    stored record, Some if exists, otherwise None

    Definition Classes
    AbstractCacheApi
  6. abstract def getAll[T](key: String*)(implicit arg0: ClassTag[T]): SynchronousResult[List[Option[T]]]

    Permalink

    Retrieve the values of all specified keys from the cache.

    Retrieve the values of all specified keys from the cache.

    key

    cache storage keys

    returns

    stored record, Some if exists, otherwise None

    Definition Classes
    AbstractCacheApi
  7. abstract def getOrElse[T](key: String, expiration: Duration = Duration.Inf)(orElse: ⇒ T)(implicit arg0: ClassTag[T]): SynchronousResult[T]

    Permalink

    Retrieve a value from the cache.

    Retrieve a value from the cache. If is missing, set default value with given expiration and return the value.

    key

    cache storage key

    expiration

    expiration period in seconds.

    orElse

    The default function to invoke if the value was not found in cache.

    returns

    stored or default record, Some if exists, otherwise None

    Definition Classes
    AbstractCacheApi
  8. abstract def getOrFuture[T](key: String, expiration: Duration = Duration.Inf)(orElse: ⇒ Future[T])(implicit arg0: ClassTag[T]): Future[T]

    Permalink

    Retrieve a value from the cache.

    Retrieve a value from the cache. If is missing, set default value with given expiration and return the value.

    key

    cache storage key

    expiration

    expiration period in seconds.

    orElse

    The default function to invoke if the value was not found in cache.

    returns

    stored or default record, Some if exists, otherwise None

    Definition Classes
    AbstractCacheApi
  9. abstract def increment(key: String, by: Long = 1): SynchronousResult[Long]

    Permalink

    Increments the stored string value representing 10-based signed integer by given value.

    Increments the stored string value representing 10-based signed integer by given value.

    key

    cache storage key

    by

    size of increment

    returns

    the value after the increment

    Definition Classes
    AbstractCacheApi
    Since

    1.3.0

  10. abstract def invalidate(): SynchronousResult[Unit]

    Permalink

    Remove all keys in cache

    Remove all keys in cache

    returns

    promise

    Definition Classes
    AbstractCacheApi
  11. abstract def list[T](key: String)(implicit arg0: ClassTag[T]): RedisList[T, SynchronousResult]

    Permalink

    Scala wrapper around Redis list-related commands.

    Scala wrapper around Redis list-related commands. This simplifies use of the lists.

    T

    type of elements within the list

    key

    the key storing the list

    returns

    Scala wrapper

    Definition Classes
    AbstractCacheApi
  12. abstract def map[T](key: String)(implicit arg0: ClassTag[T]): RedisMap[T, SynchronousResult]

    Permalink

    Scala wrapper around Redis hash-related commands.

    Scala wrapper around Redis hash-related commands. This simplifies use of the hashes, i.e., maps.

    T

    type of elements within the map

    key

    the key storing the map

    returns

    Scala wrapper

    Definition Classes
    AbstractCacheApi
  13. abstract def matching(pattern: String): SynchronousResult[Set[String]]

    Permalink

    Retrieves all keys matching the given pattern.

    Retrieves all keys matching the given pattern. This method invokes KEYS command

    Warning: complexity is O(n) where n are all keys in the database

    pattern

    valid KEYS pattern with wildcards

    returns

    list of matching keys

    Definition Classes
    AbstractCacheApi
  14. abstract def remove(key1: String, key2: String, keys: String*): SynchronousResult[Unit]

    Permalink

    Remove all values from the cache

    Remove all values from the cache

    key1

    cache storage key

    key2

    cache storage key

    keys

    cache storage keys

    returns

    promise

    Definition Classes
    AbstractCacheApi
  15. abstract def remove(key: String): SynchronousResult[Unit]

    Permalink

    Remove a value under the given key from the cache

    Remove a value under the given key from the cache

    key

    cache storage key

    returns

    promise

    Definition Classes
    AbstractCacheApi
  16. abstract def removeAll(keys: String*): SynchronousResult[Unit]

    Permalink

    Removes all keys in arguments.

    Removes all keys in arguments. The other remove methods are for syntax sugar

    keys

    cache storage keys

    returns

    promise

    Definition Classes
    AbstractCacheApi
  17. abstract def removeMatching(pattern: String): SynchronousResult[Unit]

    Permalink

    Removes all keys matching the given pattern.

    Removes all keys matching the given pattern. This command has no direct support in Redis, it is combination of KEYS and DEL commands.

    • KEYS pattern command finds all keys matching the given pattern
    • DEL keys expires all of them

    This is usable in scenarios when multiple keys contains same part of the key, such as record identification, user identification, etc. For example, we may have keys such as 'page/$id/header', 'page/$id/body', 'page/$id/footer' and we want to remove them all when the page is changed. We use the benefit of the naming convention we use and execute removeAllMatching( s"page/$id/*" ), which invalidates everything related to the given page. The benefit is we do not need to maintain the list of all keys to invalidate, we invalidate them all at once.

    Warning: complexity is O(n) where n are all keys in the database

    pattern

    this must be valid KEYS pattern

    returns

    nothing

    Definition Classes
    AbstractCacheApi
  18. abstract def set[T](key: String)(implicit arg0: ClassTag[T]): RedisSet[T, SynchronousResult]

    Permalink

    Scala wrapper around Redis set-related commands.

    Scala wrapper around Redis set-related commands. This simplifies use of the sets.

    T

    type of elements within the set

    key

    the key storing the set

    returns

    Scala wrapper

    Definition Classes
    AbstractCacheApi
  19. abstract def set(key: String, value: Any, expiration: Duration = Duration.Inf): SynchronousResult[Unit]

    Permalink

    Set a value into the cache.

    Set a value into the cache. Expiration time in seconds (0 second means eternity).

    key

    cache storage key

    value

    value to store

    expiration

    record duration in seconds

    returns

    promise

    Definition Classes
    AbstractCacheApi
  20. abstract def setAll(keyValues: (String, Any)*): SynchronousResult[Unit]

    Permalink

    Sets the given keys to their respective values for eternity.

    Sets the given keys to their respective values for eternity. If any value is null, the particular key is excluded from the operation and removed from cache instead. The operation is atomic when there are no nulls. It replaces existing values.

    keyValues

    cache storage key-value pairs to store

    returns

    promise

    Definition Classes
    AbstractCacheApi
  21. abstract def setAllIfNotExist(keyValues: (String, Any)*): SynchronousResult[Boolean]

    Permalink

    Sets the given keys to their respective values for eternity.

    Sets the given keys to their respective values for eternity. It sets all values if none of them exist, if at least a single of them exists, it does not set any value, thus it is either all or none. If any value is null, the particular key is excluded from the operation and removed from cache instead. The operation is atomic when there are no nulls.

    keyValues

    cache storage key-value pairs to store

    returns

    true if value was set, false if any value already existed before

    Definition Classes
    AbstractCacheApi
  22. abstract def setIfNotExists(key: String, value: Any, expiration: Duration = Duration.Inf): SynchronousResult[Boolean]

    Permalink

    Set a value into the cache if the given key is not already used, otherwise do nothing.

    Set a value into the cache if the given key is not already used, otherwise do nothing. Expiration time in seconds (0 second means eternity).

    Note: When expiration is defined, it is not an atomic operation. Redis does not provide a command for store-if-not-exists with duration. First, it sets the value if exists. Then, if the operation succeeded, it sets its expiration date.

    Note: When recovery policy used, it recovers with TRUE to indicate **"the lock was acquired"** despite actually **not storing** anything.

    key

    cache storage key

    value

    value to store

    expiration

    record duration in seconds

    returns

    true if value was set, false if was ignored because it existed before

    Definition Classes
    AbstractCacheApi

Concrete Value Members

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

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

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

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

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

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

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

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  16. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AbstractCacheApi[SynchronousResult]

Inherited from AnyRef

Inherited from Any

Ungrouped