import { type SyncOrAsync, type Result } from '@conduit-client/utils'; import { CacheInclusionPolicyService } from './cache-inclusion-policy'; import type { Cache, Key } from '@conduit-client/service-cache/v1'; /** * Implementation of CacheInclusionPolicy that uses an inclusive * L2 durable cache as a second level behind an in memory, synchronous, * L1 cache. */ export declare abstract class DurableCacheInclusionPolicy extends CacheInclusionPolicyService { /** * Reads data out of a 2 level inclusive store. */ read>(options: { l1: Cache; readFromL1: (l1: Cache) => SyncOrAsync; alreadyRevivedKeys?: Set; }): SyncOrAsync; /** * Writes data to a 2 level inclusive store. */ write>(options: { l1: Cache; writeToL1: (l1: Cache) => SyncOrAsync; }): SyncOrAsync; /** * Revive entries from the durable store into the L1 cache. * * Called by the framework when data is missing from L1. The * implementation MUST look up each key in the durable store and, * for every key found, write the entry to L1 via {@link Cache.set}. * * @param missingKeys Keys that were absent from L1 during the most * recent {@link read} or {@link write} attempt. Every key in this * set is guaranteed to be missing from L1. * @param l1 The L1 cache instance. Revived entries MUST be written * here so that subsequent readFromL1 calls can access them. * @returns The Set of keys that were found in the * durable store and written to L1 on this invocation. The implementation MAY * revive keys optimistically that are not explicitly requested. * * The base implementation of {@link read} uses this set to detect whether progress was made. * Returning no new keys across consecutive calls signals that no * further revives are possible, and will terminate the retry loop. */ abstract revive(missingKeys: Set, l1: Cache): SyncOrAsync>; /** * Synchronize the data from an L1 cache into the persistent levels of your cache * by reading the keys present in keys from the l1Cache, and populating them in the * durable cache. * * @param changedKeys The set of keys to synchronize to the durable cache * @param l1 The L1 cache to synchronize the data from. */ abstract syncToL2Cache(changedKeys: Set, l1: Cache): SyncOrAsync; }