diff --git a/.changeset/heavy-tables-glow.md b/.changeset/heavy-tables-glow.md new file mode 100644 index 00000000..8acba531 --- /dev/null +++ b/.changeset/heavy-tables-glow.md @@ -0,0 +1,5 @@ +--- +"@delvtech/evm-client": patch +--- + +Add `entries` property to the `SimpleCache` type. diff --git a/packages/evm-client/src/cache/factories/createLruSimpleCache.ts b/packages/evm-client/src/cache/factories/createLruSimpleCache.ts index d5c8f7b0..1cb65af7 100644 --- a/packages/evm-client/src/cache/factories/createLruSimpleCache.ts +++ b/packages/evm-client/src/cache/factories/createLruSimpleCache.ts @@ -19,6 +19,10 @@ export function createLruSimpleCache< const cache = new LRUCache(options); return { + get entries() { + return cache.entries() as Generator<[TKey, TValue]>; + }, + get(key) { return cache.get(stringify(key)); }, diff --git a/packages/evm-client/src/cache/types/SimpleCache.ts b/packages/evm-client/src/cache/types/SimpleCache.ts index 1a63513e..001d6d04 100644 --- a/packages/evm-client/src/cache/types/SimpleCache.ts +++ b/packages/evm-client/src/cache/types/SimpleCache.ts @@ -10,6 +10,11 @@ export interface SimpleCache< TValue = any, TKey extends SimpleCacheKey = SimpleCacheKey, > { + /** + * Returns an iterable of key-value pairs for every entry in the cache. + */ + readonly entries: Iterable<[TKey, TValue]>; + /** * Retrieves the value associated with the specified key. */