TCal::Cache(K, V)
Inherits MemoryCache < Reference < Object
Refinement of MemoryCache with additional behaviors.
Constructors
new(expires_in : Time::Span, clean_every : Time::Span | Nil = nil, log : Log | Nil = nil)
Creates a cache.
expires_inwill be the expiration of every cache entry;#fetchand#writeare overridden to no longer accept this.- If
clean_everyis non-nil, starts a background task that runs#cleanupon this interval. - If
logis non-nil, the background task emits an info log indicating how many entries were cleaned, when greater than zero.
Instance methods
fetch(key : K, &block : -> V) : V
Sourcewrite(key : K, value : V) : V
Source