From 12553962409fda5758f03290c7d9aff01cdd6cbe Mon Sep 17 00:00:00 2001 From: Zickles Date: Sun, 18 Feb 2024 10:13:01 -0500 Subject: [PATCH] add uuidCacheTime option --- src/Client.js | 1 + src/Private/uuidCache.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Client.js b/src/Client.js index 6d699209..e4a41a84 100644 --- a/src/Client.js +++ b/src/Client.js @@ -350,6 +350,7 @@ class Client extends EventEmitter { * @typedef {object} ClientOptions * @prop {boolean} [cache=false] Enable/Disable request caching. * @prop {number} [cacheTime=60] Amount of time in seconds to cache the requests. + * @prop {number} [uuidCacheTime=600] Amount of time in seconds to cache uuids. * @prop {CacheHandler} [cacheHandler] Custom Cache Handler * @prop {AUTO|HARD|NONE} [rateLimit='AUTO'] Rate limit mode. * @prop {boolean} [syncWithHeaders=false] Sync with headers rate limit information. Usually not necessary nor recommended ( because of latency ) diff --git a/src/Private/uuidCache.js b/src/Private/uuidCache.js index c243dec6..048bfe66 100644 --- a/src/Private/uuidCache.js +++ b/src/Private/uuidCache.js @@ -10,7 +10,11 @@ async function putCache(response) { try { response = await response.json(); cachedUuids.set(response.id, response.name); - setTimeout(deleteCache, 1000 * 60 * 10, response.id); + if (this.client.options.uuidCacheTime >= 0) { + setTimeout(deleteCache, this.client.options.uuidCacheTime * 1000, response.id); + } else { + setTimeout(deleteCache, 1000 * 60 * 10, response.id); + } } catch (e) { // F }