* 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)
| 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. |