feat: implement adding movie details from tmdb

This commit is contained in:
2023-08-01 03:15:15 +02:00
parent 3a5c5b4404
commit 01697a6686
9 changed files with 124 additions and 24 deletions

11
lib/cache/cache.ts vendored
View File

@ -30,13 +30,20 @@ const cache = await createCache();
export async function get<T>(id: string, binary = false) {
if (binary && !(cache instanceof Map)) {
return await cache.sendCommand("GET", [id], {
const cacheHit = await cache.sendCommand("GET", [id], {
returnUint8Arrays: true,
}) as T;
if (cacheHit) console.log("[cache] HIT ", { id });
else console.log("[cache] MISS", { id });
return cacheHit;
}
return await cache.get(id) as T;
const cacheHit = await cache.get(id) as T;
if (cacheHit) console.log("[cache] HIT ", { id });
else console.log("[cache] MISS", { id });
return cacheHit;
}
export async function set<T extends RedisValue>(id: string, content: T) {
console.log("[cache] storing ", { id });
return await cache.set(id, content);
}