From 11eaae12a976a9971345f598bdd9747e8c4970a3 Mon Sep 17 00:00:00 2001 From: Carlos Lostao Date: Sun, 17 Nov 2024 18:30:09 +0100 Subject: [PATCH] chore: remove file --- backend/src/services/downloadCache/index.ts | 36 --------------------- 1 file changed, 36 deletions(-) delete mode 100644 backend/src/services/downloadCache/index.ts diff --git a/backend/src/services/downloadCache/index.ts b/backend/src/services/downloadCache/index.ts deleted file mode 100644 index 9fc69d2..0000000 --- a/backend/src/services/downloadCache/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { LRUCache } from 'lru-cache' - -const cache = new LRUCache({ - maxSize: Number(process.env.MAX_CACHE_SIZE), -}) - -const has = (cid: string) => cache.has(cid) - -const get = (cid: string) => { - const value = cache.get(cid) - if (!value) { - return null - } - - return async function* () { - yield value - } -} - -const set = async function* ( - cid: string, - value: AsyncIterable, -): AsyncIterable { - let buffer = Buffer.alloc(0) - for await (const chunk of value) { - buffer = Buffer.concat([buffer, chunk]) - yield chunk - } - cache.set(cid, buffer) -} - -export const downloadCache = { - has, - get, - set, -}