mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-05 13:00:37 +08:00
fix(ACUC): do not refresh cache every set
This commit is contained in:
parent
9bdd344b36
commit
2cb493321a
@ -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
|
// Cache for 10 minutes. This means that changing subscription tier could have
|
||||||
// a maximum of 10 minutes of a delay. - mogery
|
// 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) {
|
} catch (error) {
|
||||||
Logger.error(`Error updating cached ACUC: ${error}`);
|
Logger.error(`Error updating cached ACUC: ${error}`);
|
||||||
|
@ -35,12 +35,15 @@ redisRateLimitClient.on("connect", (err) => {
|
|||||||
* @param {string} value The value to store.
|
* @param {string} value The value to store.
|
||||||
* @param {number} [expire] Optional expiration time in seconds.
|
* @param {number} [expire] Optional expiration time in seconds.
|
||||||
*/
|
*/
|
||||||
const setValue = async (key: string, value: string, expire?: number) => {
|
const setValue = async (key: string, value: string, expire?: number, nx = false) => {
|
||||||
if (expire) {
|
if (expire && !nx) {
|
||||||
await redisRateLimitClient.set(key, value, "EX", expire);
|
await redisRateLimitClient.set(key, value, "EX", expire);
|
||||||
} else {
|
} else {
|
||||||
await redisRateLimitClient.set(key, value);
|
await redisRateLimitClient.set(key, value);
|
||||||
}
|
}
|
||||||
|
if (expire && nx) {
|
||||||
|
await redisRateLimitClient.expire(key, expire, "NX");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user