Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fix(ACUC): do not refresh cache every set
Gergő Móricz2cb493321a21
diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.tsindex 91bfef1f6..130944706 100644--- a/apps/api/src/controllers/auth.ts+++ b/apps/api/src/controllers/auth.ts@@ -61,7 +61,7 @@ export async function setCachedACUC(api_key: string, acuc: AuthCreditUsageChunk// Cache for 10 minutes. This means that changing subscription tier could have// a maximum of 10 minutes of a delay. - mogery- await setValue(cacheKeyACUC, JSON.stringify(acuc), 600);+ await setValue(cacheKeyACUC, JSON.stringify(acuc), 600, true);});} catch (error) {Logger.error(`Error updating cached ACUC: ${error}`);diff --git a/apps/api/src/services/redis.ts b/apps/api/src/services/redis.tsindex 173d2b78a..608037811 100644--- a/apps/api/src/services/redis.ts+++ b/apps/api/src/services/redis.ts@@ -35,12 +35,15 @@ redisRateLimitClient.on("connect", (err) => {* @param {string} value The value to store.* @param {number} [expire] Optional expiration time in seconds.*/-const setValue = async (key: string, value: string, expire?: number) => {- if (expire) {+const setValue = async (key: string, value: string, expire?: number, nx = false) => {+ if (expire && !nx) {await redisRateLimitClient.set(key, value, "EX", expire);} else {await redisRateLimitClient.set(key, value);}+ if (expire && nx) {+ await redisRateLimitClient.expire(key, expire, "NX");+ }};/**