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

42 lines (41 loc) • 1.81 kB
import { Cache } from "../Cache.mjs"; import { AgentContext } from "../../../agent/context/AgentContext.mjs"; import "../../../agent/context/index.mjs"; //#region src/modules/cache/singleContextLruCache/SingleContextStorageLruCache.d.ts 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. * Therefor 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. */ declare class SingleContextStorageLruCache implements Cache { private limit; private _cache?; private _contextCorrelationId?; constructor({ limit }: SingleContextStorageLruCacheOptions); get<CacheValue>(agentContext: AgentContext, key: string): Promise<CacheValue | null>; set<CacheValue>(agentContext: AgentContext, key: string, value: CacheValue, expiresInSeconds?: number): Promise<void>; remove(agentContext: AgentContext, key: string): 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 export { SingleContextStorageLruCache, SingleContextStorageLruCacheOptions }; //# sourceMappingURL=SingleContextStorageLruCache.d.mts.map