/** * @since 2.0.0 */ import type * as Cache from "./Cache.js"; import type * as Duration from "./Duration.js"; import type * as Effect from "./Effect.js"; import type * as Exit from "./Exit.js"; import type * as Option from "./Option.js"; import type { Pipeable } from "./Pipeable.js"; import type * as Scope from "./Scope.js"; import type * as Types from "./Types.js"; /** * @since 2.0.0 * @category symbols */ export declare const ScopedCacheTypeId: unique symbol; /** * @since 2.0.0 * @category symbols */ export type ScopedCacheTypeId = typeof ScopedCacheTypeId; /** * @since 2.0.0 * @category models */ export interface ScopedCache extends ScopedCache.Variance, Pipeable { /** * Retrieves the value associated with the specified key if it exists. * Otherwise returns `Option.none`. */ getOption(key: Key): Effect.Effect, Error, Scope.Scope>; /** * Retrieves the value associated with the specified key if it exists and the * lookup function has completed. Otherwise returns `Option.none`. */ getOptionComplete(key: Key): Effect.Effect, never, Scope.Scope>; /** * Returns statistics for this cache. */ readonly cacheStats: Effect.Effect; /** * Return whether a resource associated with the specified key exists in the * cache. Sometime `contains` can return true if the resource is currently * being created but not yet totally created. */ contains(key: Key): Effect.Effect; /** * Return statistics for the specified entry. */ entryStats(key: Key): Effect.Effect>; /** * Gets the value from the cache if it exists or otherwise computes it, the * release action signals to the cache that the value is no longer being used * and can potentially be finalized subject to the policies of the cache. */ get(key: Key): Effect.Effect; /** * Invalidates the resource associated with the specified key. */ invalidate(key: Key): Effect.Effect; /** * Invalidates all values in the cache. */ readonly invalidateAll: Effect.Effect; /** * Force the reuse of the lookup function to compute the returned scoped * effect associated with the specified key immediately. Once the new resource * is recomputed, the old resource associated to the key is cleaned (once all * fiber using it are done with it). During the time the new resource is * computed, concurrent call the .get will use the old resource if this one is * not expired. */ refresh(key: Key): Effect.Effect; /** * Returns the approximate number of values in the cache. */ readonly size: Effect.Effect; } /** * @since 2.0.0 */ export declare namespace ScopedCache { /** * @since 2.0.0 * @category models */ interface Variance { readonly [ScopedCacheTypeId]: { _Key: Types.Contravariant; _Error: Types.Covariant; _Value: Types.Covariant; }; } } /** * Constructs a new cache with the specified capacity, time to live, and * lookup function. * * @since 2.0.0 * @category constructors */ export declare const make: (options: { readonly lookup: Lookup; readonly capacity: number; readonly timeToLive: Duration.DurationInput; }) => Effect.Effect, never, Scope.Scope | Environment>; /** * 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. * * @since 2.0.0 * @category constructors */ export declare const makeWith: (options: { readonly capacity: number; readonly lookup: Lookup; readonly timeToLive: (exit: Exit.Exit) => Duration.DurationInput; }) => Effect.Effect, never, Scope.Scope | Environment>; /** * Similar to `Cache.Lookup`, but executes the lookup function within a `Scope`. * * @since 2.0.0 * @category models */ export type Lookup = (key: Key) => Effect.Effect; //# sourceMappingURL=ScopedCache.d.ts.map