← ZIO Cache docs

Cache

zio.cache.Cache
See theCache companion class
object Cache

Attributes

Companion
class
Source
Cache.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Cache.type

Members list

Value members

Concrete methods

def make[Key, Environment, Error, Value](capacity: Int, timeToLive: Duration, lookup: Lookup[Key, Environment, Error, Value])(implicit trace: Trace): URIO[Environment, Cache[Key, Error, Value]]

Constructs a new cache with the specified capacity, time to live, and lookup function.

Constructs a new cache with the specified capacity, time to live, and lookup function.

Attributes

Source
Cache.scala
def makeWith[Key, Environment, Error, Value](capacity: Int, lookup: Lookup[Key, Environment, Error, Value])(timeToLive: Exit[Error, Value] => Duration)(implicit trace: Trace): URIO[Environment, Cache[Key, Error, Value]]

Constructs a new cache with the specified capacity, time to live, and lookup function, where the time to live can depend on the Exit value returned by the lookup function.

Constructs a new cache with the specified capacity, time to live, and lookup function, where the time to live can depend on the Exit value returned by the lookup function.

Attributes

Source
Cache.scala
def makeWithKey[In, Key, Environment, Error, Value](capacity: Int, lookup: Lookup[In, Environment, Error, Value])(timeToLive: Exit[Error, Value] => Duration, keyBy: In => Key)(implicit trace: Trace): URIO[Environment, Cache[In, Error, Value]]

Constructs a new cache with the specified capacity, time to live, and lookup function, where the time to live can depend on the Exit value returned by the lookup function.

Constructs a new cache with the specified capacity, time to live, and lookup function, where the time to live can depend on the Exit value returned by the lookup function.

This variant also allows specifying a custom keying function that will be used to to convert the input of the lookup function into the key in the underlying cache. This can be useful when the input to the lookup function is large and you do not want to store it in the cache.

Attributes

Source
Cache.scala