class

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_in will be the expiration of every cache entry; #fetch and #write are overridden to no longer accept this.
  • If clean_every is non-nil, starts a background task that runs #cleanup on this interval.
  • If log is non-nil, the background task emits an info log indicating how many entries were cleaned, when greater than zero.
Source

Instance methods

fetch(key : K, &block : -> V) : V
Source
write(key : K, value : V) : V
Source