MCPcopy
hub / github.com/redis/node-redis / set

Method set

packages/client/lib/client/cache.ts:708–734  ·  view source on GitHub ↗
(cacheKey: string, cacheEntry: ClientSideCacheEntry, keys: Array<RedisArgument>)

Source from the content-addressed store, hash-verified

706 }
707
708 set(cacheKey: string, cacheEntry: ClientSideCacheEntry, keys: Array<RedisArgument>) {
709 let count = this.#cacheKeyToEntryMap.size;
710 const oldEntry = this.#cacheKeyToEntryMap.get(cacheKey);
711
712 if (oldEntry) {
713 count--; // overwriting, so not incrementing
714 oldEntry.invalidate();
715 }
716
717 if (this.maxEntries > 0 && count >= this.maxEntries) {
718 this.deleteOldest();
719 this.#statsCounter.recordEvictions(1);
720 // Eviction due to cache capacity limit
721 publish(CHANNELS.CACHE_EVICTION, () => ({ reason: 'full', count: 1 }));
722 }
723
724 this.#cacheKeyToEntryMap.set(cacheKey, cacheEntry);
725
726 for (const key of keys) {
727 if (!this.#keyToCacheKeySetMap.has(key.toString())) {
728 this.#keyToCacheKeySetMap.set(key.toString(), new Set<string>());
729 }
730
731 const cacheKeySet = this.#keyToCacheKeySetMap.get(key.toString());
732 cacheKeySet!.add(cacheKey);
733 }
734 }
735
736 size() {
737 return this.#cacheKeyToEntryMap.size;

Callers 15

handleCacheMethod · 0.95
getFunction · 0.45
getMethod · 0.45
pool.spec.tsFile · 0.45
factoryMethod · 0.45
cache.spec.tsFile · 0.45
key-prefix.spec.tsFile · 0.45
createMethod · 0.45
subscribeMethod · 0.45

Calls 8

deleteOldestMethod · 0.95
publishFunction · 0.90
hasMethod · 0.80
invalidateMethod · 0.65
recordEvictionsMethod · 0.65
toStringMethod · 0.65
addMethod · 0.65
getMethod · 0.45

Tested by 2

listenerFunction · 0.36
runClientOperationsFunction · 0.36