createHandleCache

@atiproto/edge-resolver-cache

Factory function that returns a pre-configured TieredStore for caching ATProto handle resolution results. L1 is an in-memory LRU cache; L2 is a CacheApiStore backed by the Cloudflare Cache API. Suitable as the handleCache option for EdgeOAuthClient.

Signature

typescript
function createHandleCache(options?: CreateHandleCacheOptions): TieredStore<string, AtprotoDid | null>
OptionTypeDefaultDescription
cacheNamestring"atproto-resolver"Name of the Cache API cache passed to CacheApiStore.
l1MaxEntriesnumber1000Maximum number of entries in the in-memory L1 cache.
l1Ttlnumber600_000 (10min)TTL for the in-memory L1 cache in milliseconds.
l2TtlSecondsnumber3600 (1hr)TTL for the Cache API L2 store in seconds.

Example

typescript
import { createHandleCache } from "@atiproto/edge-resolver-cache";
import { EdgeOAuthClient } from "@atiproto/edge-oauth-client";
const client = new EdgeOAuthClient({
// ...
handleCache: createHandleCache({ cacheName: "my-cache" }),
});