A small in-memory TTL cache for MoonBit
///|
test {
let ttl : @ttl.TTL[String] = @ttl.TTL::new(default_ttl_ms=10_000L)
assert_true(ttl.set("foo", "bar", now_ms=0L))
guard ttl.get("foo", now_ms=1L) is Some("bar") else {
fail("expected foo hit")
}
guard ttl.get("foo", now_ms=10_000L) is None else {
fail("expected foo to expire")
}
}A small in-memory TTL cache for MoonBit