← ZIO Cache docs

zio.cache

package zio.cache

Members list

Type members

Classlikes

abstract class Cache[-Key, +Error, +Value]

A Cache is defined in terms of a lookup function that, given a key of type Key, can either fail with an error of type Error or succeed with a value of type Value. Getting a value from the cache will either return the previous result of the lookup function if it is available or else compute a new result with the lookup function, put it in the cache, and return it.

A Cache is defined in terms of a lookup function that, given a key of type Key, can either fail with an error of type Error or succeed with a value of type Value. Getting a value from the cache will either return the previous result of the lookup function if it is available or else compute a new result with the lookup function, put it in the cache, and return it.

A cache also has a specified capacity and time to live. When the cache is at capacity the least recently accessed values in the cache will be removed to make room for new values. Getting a value with a life older than the specified time to live will result in a new value being computed with the lookup function and returned when available.

The cache is safe for concurrent access. If multiple fibers attempt to get the same key the lookup function will only be computed once and the result will be returned to all fibers.

Attributes

Companion
object
Source
Cache.scala
Supertypes
class Object
trait Matchable
class Any
object Cache

Attributes

Companion
class
Source
Cache.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Cache.type
final case class CacheStats(hits: Long, misses: Long, size: Int)

CacheStats represents a snapshot of statistics for the cache as of a point in time.

CacheStats represents a snapshot of statistics for the cache as of a point in time.

Attributes

Source
CacheStats.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class EntryStats(loaded: Instant)

EntryStats represents a snapshot of statistics for an entry in the cache.

EntryStats represents a snapshot of statistics for an entry in the cache.

Attributes

Source
EntryStats.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class Lookup[-Key, -Environment, +Error, +Value](lookup: Key => ZIO[Environment, Error, Value]) extends Key => ZIO[Environment, Error, Value]

A Lookup represents a lookup function that, given a key of type Key, can return a ZIO effect that will either produce a value of type Value or fail with an error of type Error using an environment of type Environment.

A Lookup represents a lookup function that, given a key of type Key, can return a ZIO effect that will either produce a value of type Value or fail with an error of type Error using an environment of type Environment.

You can think of a Lookup as an effectual function that computes a value given a key. Given any effectual function you can convert it to a lookup function for a cache by using the Lookup constructor.

Attributes

Source
Lookup.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait Key => ZIO[Environment, Error, Value]
class Object
trait Matchable
class Any
Show all
object ScopedCache

Attributes

Companion
class
Source
ScopedCache.scala
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class ScopedCache[-Key, +Error, +Value]

Attributes

Companion
object
Source
ScopedCache.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Source
ScopedCacheImplementation.scala
Supertypes
class Object
trait Matchable
class Any
Self type
final case class ScopedLookup[-Key, -Environment, +Error, +Value](lookup: Key => ZIO[Environment & Scope, Error, Value]) extends Key => ZIO[Environment & Scope, Error, Value]

Like lookup but scoped version

Like lookup but scoped version

Attributes

Source
ScopedLookup.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait Key => ZIO[Environment & Scope, Error, Value]
class Object
trait Matchable
class Any
Show all