UNPKG

@credo-ts/core

Version:

<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1

41 lines • 2.03 kB
import { Cache, CacheOptions } from "../Cache.mjs"; import { AgentContext } from "../../../agent/context/AgentContext.mjs"; import "../../../agent/context/index.mjs"; //#region src/modules/cache/singleContextLruCache/SingleContextStorageLruCache.d.ts export interface SingleContextStorageLruCacheOptions { /** The maximum number of entries allowed in the cache */ limit: number; } /** * Cache that leverages the storage associated with the agent context to store cache records. * It will keep an in-memory cache of the records to avoid hitting the storage on every read request. * Therefore this cache is meant to be used with a single instance of the agent. * * Due to keeping an in-memory copy of the cache, it is also not meant to be used with multiple * agent context instances (meaning multi-tenancy), as they will overwrite the in-memory cache. * * However, this means the cache is not meant for usage with multiple instances. * * This cache does not honor {@link CacheOptions.scope}: as it must only ever be used with a single * agent context (enforced at runtime), the context and global scopes are equivalent within it. */ export declare class SingleContextStorageLruCache implements Cache { private limit; private _cache?; private _contextCorrelationId?; constructor({ limit }: SingleContextStorageLruCacheOptions); get<CacheValue>(agentContext: AgentContext, key: string, _options?: CacheOptions): Promise<CacheValue | null>; set<CacheValue>(agentContext: AgentContext, key: string, value: CacheValue, expiresInSeconds?: number, _options?: CacheOptions): Promise<void>; remove(agentContext: AgentContext, key: string, _options?: CacheOptions): Promise<void>; private getCache; private lruFromRecord; private fetchCacheRecord; private removeExpiredItems; private persistCache; /** * Asserts this class is not used with multiple agent context instances. */ private assertContextCorrelationId; } //#endregion //# sourceMappingURL=SingleContextStorageLruCache.d.mts.map