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

Method delete

cache/ttl_cache.ts:287–299  ·  view source on GitHub ↗

* Deletes the value associated with the given key. * * @experimental **UNSTABLE**: New API, yet to be vetted. * * @param key The key to delete. * @returns `true` if the key was deleted, `false` otherwise. * * @example Usage * ```ts * import { TtlCache } from "@std/cache";

(key: K)

Source from the content-addressed store, hash-verified

285 * ```
286 */
287 override delete(key: K): boolean {
288 const value = super.get(key);
289 const existed = super.delete(key);
290 if (!existed) return false;
291
292 const timeout = this.#timeouts.get(key);
293 if (timeout !== undefined) clearTimeout(timeout);
294 this.#timeouts.delete(key);
295 this.#entryTtls?.delete(key);
296 this.#absoluteDeadlines?.delete(key);
297 this.#eject?.(key, value!);
298 return true;
299 }
300
301 /**
302 * Clears the cache.

Callers 2

setMethod · 0.95
#resetTtlMethod · 0.95

Calls 2

getMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected