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>
| Option | Type | Default | Description |
|---|---|---|---|
| cacheName | string | "atproto-resolver" | Name of the Cache API cache passed to CacheApiStore. |
| l1MaxEntries | number | 1000 | Maximum number of entries in the in-memory L1 cache. |
| l1Ttl | number | 600_000 (10min) | TTL for the in-memory L1 cache in milliseconds. |
| l2TtlSeconds | number | 3600 (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" }),});
Related
- createDidCache — equivalent factory for DID document caching
- TieredStore — the underlying two-tier cache class