class

Session::LocalCache(T)

Inherits Reference < Object

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)
Source

Instance methods

clear

Clear all entries from the cache

Source
delete(key : String) : Bool

Remove a key from the cache

Source
get(key : String) : T | Nil

Get a value from the cache, returning nil if expired or missing

Source
reset_stats

Reset statistics counters

Source
set(key : String, value : T) : T

Store a value in the cache with automatic TTL

Source
size

Count of valid (non-expired) entries

Source
stats

Get cache statistics

Source

Nested types