Cache

trait Cache[F[_], V] extends CacheAlg[F, V]
trait CacheAlg[F, V]
class Object
trait Matchable
class Any
trait AbstractCache[F, V]

Value members

Abstract methods

def cachingForMemoize(baseKey: String)(ttl: Option[Duration])(f: => V)(implicit flags: Flags): F[V]
def cachingForMemoizeF(baseKey: String)(ttl: Option[Duration])(f: F[V])(implicit flags: Flags): F[V]

Inherited methods

def caching(keyParts: Any*)(ttl: Option[Duration])(f: => V)(implicit flags: Flags): F[V]

Get a value from the cache if it exists. Otherwise compute it, insert it into the cache, and return it.

Get a value from the cache if it exists. Otherwise compute it, insert it into the cache, and return it.

Value Params
f

A block that computes the value

flags

Flags used to conditionally alter the behaviour of ScalaCache

keyParts

The cache key

ttl

The time-to-live to use when inserting into the cache. The cache entry will expire after this time has elapsed.

Returns

The value, either retrieved from the cache or computed

Inherited from
CacheAlg
def cachingF(keyParts: Any*)(ttl: Option[Duration])(f: F[V])(implicit flags: Flags): F[V]

Get a value from the cache if it exists. Otherwise compute it, insert it into the cache, and return it.

Get a value from the cache if it exists. Otherwise compute it, insert it into the cache, and return it.

Value Params
f

A block that computes the value wrapped in a container

flags

Flags used to conditionally alter the behaviour of ScalaCache

keyParts

The cache key

ttl

The time-to-live to use when inserting into the cache. The cache entry will expire after this time has elapsed.

Returns

The value, either retrieved from the cache or computed

Inherited from
CacheAlg
def close: F[Unit]

You should call this when you have finished using this Cache. (e.g. when your application shuts down)

You should call this when you have finished using this Cache. (e.g. when your application shuts down)

It will take care of gracefully shutting down the underlying cache client.

Note that you should not try to use this Cache instance after you have called this method.

Inherited from
CacheAlg
def get(keyParts: Any*)(implicit flags: Flags): F[Option[V]]

Get a value from the cache

Get a value from the cache

Value Params
flags

Flags used to conditionally alter the behaviour of ScalaCache

keyParts

The cache key

Returns

The appropriate value, if it was found in the cache

Inherited from
CacheAlg
def put(keyParts: Any*)(value: V, ttl: Option[Duration])(implicit flags: Flags): F[Unit]

Insert a value into the cache, optionally setting a TTL (time-to-live)

Insert a value into the cache, optionally setting a TTL (time-to-live)

Value Params
flags

Flags used to conditionally alter the behaviour of ScalaCache

keyParts

The cache key

ttl

The time-to-live. The cache entry will expire after this time has elapsed.

value

The value to insert

Inherited from
CacheAlg
def remove(keyParts: Any*): F[Unit]

Remove the given key and its associated value from the cache, if it exists. If the key is not in the cache, do nothing.

Remove the given key and its associated value from the cache, if it exists. If the key is not in the cache, do nothing.

Value Params
keyParts

data to be used to generate the cache key. This could be as simple as just a single String. See CacheKeyBuilder.

Inherited from
CacheAlg
def removeAll: F[Unit]

Delete the entire contents of the cache. Use wisely!

Delete the entire contents of the cache. Use wisely!

Inherited from
CacheAlg