AxContextCacheRegistry
type AxContextCacheRegistry = object;Defined in: https://github.com/ax-llm/ax/blob/7965c876f6a5b641e0cf166e8942e540cfde65e1/src/ax/ai/types.ts#L821
External registry for persisting context cache metadata. Useful for serverless/short-lived processes where in-memory storage is lost. Registry keys identify cacheable content, not users or accounts. Applications that require tenant isolation must add a stable tenant/account namespace and must not fall back to a shared global namespace.
Example
// Redis-backed registry
const tenantId = getRequiredTenantId();
const registry: AxContextCacheRegistry = {
get: async (key) => {
const data = await redis.get(`cache:${tenantId}:${key}`);
return data ? JSON.parse(data) : undefined;
},
set: async (key, entry) => {
const ttl = Math.max(1, Math.ceil((entry.expiresAt - Date.now()) / 1000));
await redis.set(`cache:${tenantId}:${key}`, JSON.stringify(entry), 'EX', ttl);
},
};Properties
get()
get: (key: string) =>
| Promise<
| AxContextCacheRegistryEntry
| undefined>
| AxContextCacheRegistryEntry
| undefined;Defined in: https://github.com/ax-llm/ax/blob/7965c876f6a5b641e0cf166e8942e540cfde65e1/src/ax/ai/types.ts#L823
Look up a cache entry by key
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
| Promise<
| AxContextCacheRegistryEntry
| undefined>
| AxContextCacheRegistryEntry
| undefined
set()
set: (key: string, entry: Readonly<AxContextCacheRegistryEntry>) => Promise<void> | void;Defined in: https://github.com/ax-llm/ax/blob/7965c876f6a5b641e0cf166e8942e540cfde65e1/src/ax/ai/types.ts#L830
Store a cache entry
Parameters
| Parameter | Type |
|---|---|
key | string |
entry | Readonly<AxContextCacheRegistryEntry> |
Returns
Promise<void> | void