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>
| Option | Type | Default | Description |
|---|---|---|---|
| cacheName | string | "atproto-resolver" | Name of the Cache API cache passed to CacheApiStore. |
| l1MaxSize | number | ~50 MB | Maximum byte size of the in-memory L1 cache. |
| l1Ttl | number | 3_600_000 (1hr) | TTL for the in-memory L1 cache in milliseconds. |
| l2TtlSeconds | number | 86400 (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" }),});
Related
- createHandleCache — equivalent factory for handle resolution caching
- TieredStore — the underlying two-tier cache class