MCPcopy Create free account
hub / github.com/denoland/std / set

Method set

cache/lru_cache.ts:264–274  ·  view source on GitHub ↗

* Sets the specified key to the specified value. * * @param key The key to set the value for. * @param value The value to set. * @returns `this` for chaining. * * @example Setting a value in the cache * ```ts no-assert * import { LruCache } from "@std/cache"; * * const

(key: K, value: V)

Source from the content-addressed store, hash-verified

262 * ```
263 */
264 override set(key: K, value: V): this {
265 if (this.#ejecting) {
266 throw new TypeError(
267 "Cannot set entry in LruCache: cache is not re-entrant during onEject callbacks",
268 );
269 }
270 this.#setMostRecentlyUsed(key, value);
271 this.#pruneToMaxSize();
272
273 return this;
274 }
275
276 /**
277 * Deletes the value associated with the given key.

Callers

nothing calls this directly

Calls 2

#setMostRecentlyUsedMethod · 0.95
#pruneToMaxSizeMethod · 0.95

Tested by

no test coverage detected