ttl-cache
Simple TTL cache library for deno.
Usage
import { Cache } from "https://deno.land/x/ttl_cache@$MODULE_VERSION/mod.ts";
// Create a cache instance that has 1000 ms TTL (default)
const cache = new Cache<string, string>(1000);
// Set
// key1 will be removed after 1000 ms
// key2 will be removed after 5000 ms
cache
.set("key1", "value")
.set("key2", "value", { ttl: 5000 });
// Size
cache.size(); // => 2
// Get
cache.get("key1"); // => "value"
// Has
cache.has("key1"); // => true
// Delete
cache.delete("key1"); // => true
// Clear
cache.clear();
License
The code follows MIT license written in LICENSE. Contributors need to agree that any modifications sent in this repository follow the license.