trait CacheAsyncApi extends AbstractCacheApi[AsynchronousResult]
Asynchronous non-blocking implementation of the connection to the redis database
- Alphabetic
- By Inheritance
- CacheAsyncApi
- AbstractCacheApi
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def append(key: String, value: String, expiration: Duration = Duration.Inf): AsynchronousResult[Done]
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
- abstract def decrement(key: String, by: Long = 1): AsynchronousResult[Long]
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
- abstract def exists(key: String): AsynchronousResult[Boolean]
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
- abstract def expire(key: String, expiration: Duration): AsynchronousResult[Done]
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
- abstract def expiresIn(key: String): AsynchronousResult[Option[Duration]]
Returns the remaining time to live of a key that has an expire set, useful, e.g., when we want to check remaining session duration
Returns the remaining time to live of a key that has an expire set, useful, e.g., when we want to check remaining session duration
- key
cache storage key
- returns
the remaining time to live of a key. Some finite duration when the value exists and the expiration is set, Some infinite duration when the value exists but never expires, and None when the key does not exist.
- Definition Classes
- AbstractCacheApi
- abstract def get[T](key: String)(implicit arg0: ClassTag[T]): AsynchronousResult[Option[T]]
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
- abstract def getAll[T](keys: Iterable[String])(implicit arg0: ClassTag[T]): AsynchronousResult[Seq[Option[T]]]
Retrieve the values of all specified keys from the cache.
Retrieve the values of all specified keys from the cache.
- keys
a collection of cache storage keys
- returns
stored record, Some if exists, otherwise None
- Definition Classes
- AbstractCacheApi
- abstract def getOrElse[T](key: String, expiration: Duration = Duration.Inf)(orElse: => T)(implicit arg0: ClassTag[T]): AsynchronousResult[T]
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.
Lazy invocation (default): The method **does wait** for the result of
setand when it fails, it applies the recovery policy.Eager invocation: The method **does not wait** for the result of
setif the value is not cached and also does not apply recovery policy if thesetfails.- 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
- abstract def getOrFuture[T](key: String, expiration: Duration = Duration.Inf)(orElse: => Future[T])(implicit arg0: ClassTag[T]): Future[T]
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.
Lazy invocation (default): The method **does wait** for the result of
setand when it fails, it applies the recovery policy.Eager invocation: The method **does not wait** for the result of
setif the value is not cached and also does not apply recovery policy if thesetfails.- 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
- abstract def increment(key: String, by: Long = 1): AsynchronousResult[Long]
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
- abstract def invalidate(): AsynchronousResult[Done]
Remove all keys in cache
Remove all keys in cache
- returns
promise
- Definition Classes
- AbstractCacheApi
- abstract def list[T](key: String)(implicit arg0: ClassTag[T]): RedisList[T, AsynchronousResult]
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
- abstract def map[T](key: String)(implicit arg0: ClassTag[T]): RedisMap[T, AsynchronousResult]
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
- abstract def matching(pattern: String): AsynchronousResult[Seq[String]]
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
- abstract def remove(key1: String, key2: String, keys: String*): AsynchronousResult[Done]
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
- abstract def remove(key: String): AsynchronousResult[Done]
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
- abstract def removeAll(keys: String*): AsynchronousResult[Done]
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
- abstract def removeMatching(pattern: String): AsynchronousResult[Done]
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 patterncommand finds all keys matching the given patternDEL keysexpires 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
- abstract def set[T](key: String)(implicit arg0: ClassTag[T]): RedisSet[T, AsynchronousResult]
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
- abstract def set(key: String, value: Any, expiration: Duration = Duration.Inf): AsynchronousResult[Done]
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
- abstract def setAll(keyValues: (String, Any)*): AsynchronousResult[Done]
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
- abstract def setAllIfNotExist(keyValues: (String, Any)*): AsynchronousResult[Boolean]
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
- abstract def setIfNotExists(key: String, value: Any, expiration: Duration = Duration.Inf): AsynchronousResult[Boolean]
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
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def getAll[T](key: String*)(implicit arg0: ClassTag[T]): AsynchronousResult[Seq[Option[T]]]
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
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
- Deprecated
(Since version ) see corresponding Javadoc for more information.