import {SQLiteCache} from 'sqlite-cache'; import {Type} from '@sinclair/typebox'; const DB_NAME = './cache.db' const LOGGING_ENABLED = false; type Identity = { handle: string; } type AccountMetadata = { did: string; displayName: string; handle: string; avatarCid: string | null; } // Define your data schema const IdentitySchema = Type.Object({ handle: Type.String(), }) const AccountMetadataSchema = Type.Object({ did: Type.String(), displayName: Type.String(), handle: Type.String(), avatarCid: Type.Union([Type.String(), Type.Null()]), }) const identityCache = new SQLiteCache({ path: DB_NAME, schema: IdentitySchema, ttl: 60_000 * 60, // 1 hour max: 1000, // Maximum 1000 entries log: LOGGING_ENABLED // Enable logging }) const accountMetadataCache = new SQLiteCache({ path: DB_NAME, schema: AccountMetadataSchema, ttl: 60_000 * 10, // 1 hour max: 1000, // Maximum 1000 entries log: LOGGING_ENABLED // Enable logging }) export { identityCache, accountMetadataCache }; export type { AccountMetadata }; export default identityCache;