Files
el/tests/time/examples/ttl-cache.el
Will Anderson e7c2fd02df add Instant + Duration as first-class types in El
Postfix literal syntax (30.seconds, 1.hour). Type-checked arithmetic
(Instant + Duration -> Instant; Instant + Instant fails). TTL helpers
backed by typed Duration. sleep(Duration) replaces ambiguous sleep(Int).

Self-host fixed point holds at 5797 lines.
Snapshot tagged at dist/platform/elc.20260502-1256-self-host.

Phase 2 (every/after/at scheduling primitives) lands separately.
Backlog: bl-937e9c30
2026-05-02 12:57:13 -05:00

15 lines
444 B
EmacsLisp

// ttl-cache.el TTL helpers backed by typed Duration. Storing under a key
// stamps the set time as an Instant; ttl_cache_get computes the age and
// returns the value only if the age is within the supplied Duration.
// `test` is reserved; using `run_test` instead.
fn run_test() -> String {
ttl_cache_set("key1", "hello")
let v: String = ttl_cache_get("key1", 1.hour)
return v
}
fn main() -> Void {
println(run_test())
}