diff --git a/src/identity/profileCache.ts b/src/identity/profileCache.ts --- a/src/identity/profileCache.ts +++ b/src/identity/profileCache.ts @@ -105,50 +105,3 @@ return result; }, ); - -export type DebugCacheEntry = - | { status: "hit"; profile: Profile | null; updatedAt: number; ageMs: number; expired: boolean } - | { status: "miss" } - | { status: "malformed"; raw: string } - | { status: "disabled" }; - -export async function debugReadCache( - dids: string[], -): Promise> { - const out = new Map(); - if (!redisClient) { - for (const did of dids) out.set(did, { status: "disabled" }); - return out; - } - if (dids.length === 0) return out; - - const raw = await redisClient.mget(...dids.map(profileKey)); - const now = Date.now(); - raw.forEach((value, i) => { - const did = dids[i]; - if (!value) { - out.set(did, { status: "miss" }); - return; - } - try { - const entry = JSON.parse(value) as CachedEntry; - const ageMs = now - entry.updatedAt; - out.set(did, { - status: "hit", - profile: entry.profile, - updatedAt: entry.updatedAt, - ageMs, - expired: ageMs > MAX_TTL * 1000, - }); - } catch { - out.set(did, { status: "malformed", raw: value }); - } - }); - return out; -} - -export async function debugFetchProfiles( - dids: string[], -): Promise> { - return fetchProfiles(dids); -} diff --git a/app/debug/profile-cache/page.tsx b/app/debug/profile-cache/page.tsx deleted file mode 100644 --- a/app/debug/profile-cache/page.tsx +++ /dev/null @@ -1,199 +0,0 @@ -import { - debugFetchProfiles, - debugReadCache, - type DebugCacheEntry, - type Profile, -} from "src/identity/profileCache"; - -export const dynamic = "force-dynamic"; -export const runtime = "nodejs"; - -type SearchParams = Promise<{ dids?: string }>; - -export default async function ProfileCacheDebugPage({ - searchParams, -}: { - searchParams: SearchParams; -}) { - const { dids: didsParam } = await searchParams; - const dids = parseDids(didsParam); - - let rows: { - did: string; - cache: DebugCacheEntry; - live: Profile | null; - }[] = []; - - if (dids.length > 0) { - const [cacheEntries, fetched] = await Promise.all([ - debugReadCache(dids), - debugFetchProfiles(dids), - ]); - rows = dids.map((did) => ({ - did, - cache: cacheEntries.get(did) ?? { status: "miss" }, - live: fetched.get(did) ?? null, - })); - } - - return ( -
-

Profile Cache Debug

-

- Shows what's in the Redis cache and what bsky's - getProfiles returns right now. The cache is not updated. -

- -
- -