feat: implement adding movie details from tmdb
This commit is contained in:
11
lib/cache/cache.ts
vendored
11
lib/cache/cache.ts
vendored
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user