An event store, or anything with its insert$ stream.
The cache to write to and read from.
batchTime and maxBatchSize for the writes.
cacheRequest and stop, which ends the writes.
import { EventStore } from 'applesauce-core';
import { attachEventCache, createMemoryCacheAdapter } from '@kernlize/core/cache';
const store = new EventStore();
const attached = attachEventCache(store, await createMemoryCacheAdapter().open());
await attached.cacheRequest([{ kinds: [0], limit: 1 }]);
attached.stop();
Wire a cache to an event store. New events the store receives are written in batches through applesauce's
persistEventsToCache, which skips events that came from the cache.cacheRequestis what applesauce loaders take as theircacheRequest: it marks every event it returns as from the cache, and resolves nothing when the cache cannot answer, because a cache is an accelerator, never identity.