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, -}