← ZIO Query docs

Cache

zio.query.Cache
See theCache companion object
trait Cache

A Cache maintains an internal state with a mapping from requests to Promises that will contain the result of those requests when they are executed. This is used internally by the library to provide deduplication and caching of requests.

Attributes

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

Members list

Value members

Abstract methods

def get[E, A](request: Request[E, A])(implicit trace: Trace): IO[Unit, Promise[E, A]]

Looks up a request in the cache, failing with the unit value if the request is not in the cache or succeeding with a Promise if the request is in the cache that will contain the result of the request when it is executed.

Looks up a request in the cache, failing with the unit value if the request is not in the cache or succeeding with a Promise if the request is in the cache that will contain the result of the request when it is executed.

Attributes

Source
Cache.scala
def lookup[E, A, B](request: A)(implicit ev: A <:< Request[E, B], trace: Trace): UIO[Either[Promise[E, B], Promise[E, B]]]

Looks up a request in the cache. If the request is not in the cache returns a Left with a Promise that can be completed to complete the request. If the request is in the cache returns a Right with a Promise that will contain the result of the request when it is executed.

Looks up a request in the cache. If the request is not in the cache returns a Left with a Promise that can be completed to complete the request. If the request is in the cache returns a Right with a Promise that will contain the result of the request when it is executed.

Attributes

Source
Cache.scala
def put[E, A](request: Request[E, A], result: Promise[E, A])(implicit trace: Trace): UIO[Unit]

Inserts a request and a Promise that will contain the result of the request when it is executed into the cache.

Inserts a request and a Promise that will contain the result of the request when it is executed into the cache.

Attributes

Source
Cache.scala
def remove[E, A](request: Request[E, A])(implicit trace: Trace): UIO[Unit]

Removes a request from the cache.

Removes a request from the cache.

Attributes

Source
Cache.scala