collectionCache<T>(fetchAll: () => Promise<T[]>,ttlMs: number,now?: () => number): CollectionCache<T>
Create an in-memory collection cache with TTL. Loads all items via fetchAll on first access or after invalidation/expiry, then serves from memory until the TTL expires or invalidate() is called. Accepts an optional clock function for testing.
Uses a generation counter to prevent a race condition where a concurrent fetchAll() that started before an invalidation could overwrite the cache with stale data.