From 99a1e46b93c2e5cdbb6f080f7a60c2de27532ec4 Mon Sep 17 00:00:00 2001 From: rjawesome Date: Mon, 29 Jul 2024 11:24:33 -0700 Subject: [PATCH] caching prefix retriever->bte --- src/cache.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cache.ts b/src/cache.ts index e9bcad4..b5e5cd3 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -2,7 +2,7 @@ import { Readable, Transform } from "stream"; import lz4 from "lz4"; import { redisClient } from "./redis-client"; import Debug from "debug"; -const debug = Debug("retriever:caching"); +const debug = Debug("bte:caching"); export async function cacheContent( hash: string, @@ -14,11 +14,11 @@ export async function cacheContent( } debug(`Caching ${content.length} items for article ${hash}`); - const cacheID = `retriever:cacheContent:${hash}`; + const cacheID = `bte:cacheContent:${hash}`; let success = false; await redisClient.client.usingLock( - [`retriever:cachingLock:${hash}`], + [`bte:cachingLock:${hash}`], 30000, async () => { try { @@ -70,7 +70,7 @@ async function cacheChunk( chunk: string, reject: { (reason: any): void; (arg0: any): void }, ) { - const id = `retriever:cacheContent:${hash}`; + const id = `bte:cacheContent:${hash}`; try { await redisClient.client.hsetTimeout(id, String(index++), chunk); } catch (error) { @@ -92,11 +92,11 @@ export async function cacheLookup(hash: string): Promise { return null; } debug(`Beginning cache lookup for article ${hash}`); - const id = `retriever:cacheContent:${hash}`; + const id = `bte:cacheContent:${hash}`; const content = await new Promise(resolve => { redisClient.client.usingLock( - [`retriever: cachingLock:${hash} `], + [`bte: cachingLock:${hash} `], 30000, async () => readFromCache(hash, resolve), ); @@ -127,7 +127,7 @@ async function readFromCache( hash: string, resolve: (value: any | null) => void, ): Promise { - const id = `retriever:cacheContent:${hash}`; + const id = `bte:cacheContent:${hash}`; try { const compressedContent = await redisClient.client.hgetallTimeout(id); if (!(compressedContent && Object.keys(compressedContent).length)) {