mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-09 16:52:13 +01:00
One less call when dealing with lru cache
This commit is contained in:
parent
6e5f4f7610
commit
17059fdbe6
1 changed files with 3 additions and 2 deletions
|
@ -104,9 +104,10 @@ if (config.redis?.enabled) {
|
|||
const createKeyName = (key: RedisCommandArgument) => (key + (config.redis.useCompression ? ".c" : "")) as RedisCommandArgument;
|
||||
|
||||
exportClient.getWithCache = (key) => {
|
||||
if (cache && cacheClient && cache.has(key)) {
|
||||
const cachedItem = cache && cacheClient && cache.get(key);
|
||||
if (cachedItem != null) {
|
||||
memoryCacheHits++;
|
||||
return Promise.resolve(cache.get(key));
|
||||
return Promise.resolve(cachedItem);
|
||||
} else if (shouldClientCacheKey(key)) {
|
||||
memoryCacheMisses++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue