/* c8 ignore start - interface only */ import type { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces.ts'; import type { CacheLoadResult } from './internal/ReadThroughEntityCache.ts'; /** * A cache adapter is an interface by which objects can be * cached, fetched from cache, and removed from cache (invalidated). */ export interface IEntityCacheAdapter< TFields extends Record, TIDField extends keyof TFields, > { /** * Load many objects from cache. * @param key - load key to load * @param values - load values to load for the key * @returns map from all load values to a CacheLoadResult for that value */ loadManyAsync< TLoadKey extends IEntityLoadKey, TSerializedLoadValue, TLoadValue extends IEntityLoadValue, >( key: TLoadKey, values: readonly TLoadValue[], ): Promise>>; /** * Cache many objects fetched from the DB. * @param key - load key to cache * @param objectMap - map from load value to object to cache for the key */ cacheManyAsync< TLoadKey extends IEntityLoadKey, TSerializedLoadValue, TLoadValue extends IEntityLoadValue, >( key: TLoadKey, objectMap: ReadonlyMap>, ): Promise; /** * Negatively cache objects that could not be found in the cache or DB. * @param key - load key to cache misses for * @param values - load values for objects reported as CacheStatus.NEGATIVE * in the cache and not found in the DB. */ cacheDBMissesAsync< TLoadKey extends IEntityLoadKey, TSerializedLoadValue, TLoadValue extends IEntityLoadValue, >( key: TLoadKey, values: readonly TLoadValue[], ): Promise; /** * Invalidate the cache for objects cached by (key, value). * @param key - load key to invalidate * @param values - load values to be invalidated for the key */ invalidateManyAsync< TLoadKey extends IEntityLoadKey, TSerializedLoadValue, TLoadValue extends IEntityLoadValue, >( key: TLoadKey, values: readonly TLoadValue[], ): Promise; } /* c8 ignore stop - interface only */