Local cache with TTL and LRU eviction
Generic parameter T can be any type - when used for sessions, instantiate as LocalCache(T)
where T is your session class that inherits from Session::Base
Constructors
new(ttl : Time::Span = 30.seconds, max_size : Int32 = 10000)
SourceInstance methods
clear
Clear all entries from the cache
Sourcedelete(key : String) : Bool
Remove a key from the cache
Sourceget(key : String) : T | Nil
Get a value from the cache, returning nil if expired or missing
Sourcereset_stats
Reset statistics counters
Sourceset(key : String, value : T) : T
Store a value in the cache with automatic TTL
Sourcesize
Count of valid (non-expired) entries
Source