createDidCache

@atiproto/edge-resolver-cache

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

Signature

typescript
function createDidCache(options?: CreateDidCacheOptions): TieredStore<Did, DidDocument>
OptionTypeDefaultDescription
cacheNamestring"atproto-resolver"Name of the Cache API cache passed to CacheApiStore.
l1MaxSizenumber~50 MBMaximum byte size of the in-memory L1 cache.
l1Ttlnumber3_600_000 (1hr)TTL for the in-memory L1 cache in milliseconds.
l2TtlSecondsnumber86400 (24hr)TTL for the Cache API L2 store in seconds.

Example

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