/** * @since 1.0.0 */ import type * as Either from "@effect/data/Either"; import type * as Option from "@effect/data/Option"; import type * as Effect from "@effect/io/Effect"; import type * as Ref from "@effect/io/Ref"; import type * as Request from "@effect/query/Request"; /** * @since 1.0.0 * @category symbols */ export declare const CacheTypeId: unique symbol; /** * @since 1.0.0 * @category symbols */ export type CacheTypeId = typeof CacheTypeId; /** * A `Cache` maintains an internal state with a mapping from requests to `Ref`s * 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. * * @since 1.0.0 * @category models */ export interface Cache extends Cache.Proto { /** * Looks up a request in the cache, failing with the unit value if the request * is not in the cache, succeeding with `Ref(None)` if the request is in the * cache but has not been executed yet, or `Ref(Some(value))` if the request * has been executed. */ get(request: Request.Request): Effect.Effect>>>; /** * Looks up a request in the cache. If the request is not in the cache returns * a `Left` with a `Ref` that can be set with a `Some` to complete the * request. If the request is in the cache returns a `Right` with a `Ref` that * either contains `Some` with a result if the request has been executed or * `None` if the request has not been executed yet. */ lookup(request: Request.Request): Effect.Effect>>, Ref.Ref>>>>; /** * Inserts a request and a `Ref` that will contain the result of the request * when it is executed into the cache. */ set(request: Request.Request, result: Ref.Ref>>): Effect.Effect; /** * Removes a request from the cache. */ remove(request: Request.Request): Effect.Effect; } /** * @since 1.0.0 */ export declare namespace Cache { /** * @since 1.0.0 * @category models */ interface Proto { readonly [CacheTypeId]: CacheTypeId; } } /** * Constructs an empty cache. * * @since 1.0.0 * @category constructors */ export declare const empty: () => Effect.Effect; /** * Looks up a request in the cache, failing with the unit value if the request * is not in the cache, succeeding with `Ref(None)` if the request is in the * cache but has not been executed yet, or `Ref(Some(value))` if the request * has been executed. * * @since 1.0.0 * @category elements */ export declare const get: { (request: Request.Request): (self: Cache) => Effect.Effect>>>; (self: Cache, request: Request.Request): Effect.Effect>>>; }; /** * Looks up a request in the cache. If the request is not in the cache returns * a `Left` with a `Ref` that can be set with a `Some` to complete the * request. If the request is in the cache returns a `Right` with a `Ref` that * either contains `Some` with a result if the request has been executed or * `None` if the request has not been executed yet. * * @since 1.0.0 * @category elements */ export declare const lookup: { (request: Request.Request): (self: Cache) => Effect.Effect>>, Ref.Ref>>>>; (self: Cache, request: Request.Request): Effect.Effect>>, Ref.Ref>>>>; }; /** * Inserts a request and a `Ref` that will contain the result of the request * when it is executed into the cache. * * @since 1.0.0 * @category mutations */ export declare const set: { (request: Request.Request, result: Ref.Ref>>): (self: Cache) => Effect.Effect; (self: Cache, request: Request.Request, result: Ref.Ref>>): Effect.Effect; }; /** * Removes a request from the cache. * * @since 1.0.0 * @category mutations */ export declare const remove: { (request: Request.Request): (self: Cache) => Effect.Effect; (self: Cache, request: Request.Request): Effect.Effect; }; //# sourceMappingURL=Cache.d.ts.map