class TCal::Cache(K, V)

Overview

Refinement of MemoryCache with additional behaviors.

Defined in:

t_cal/cache.cr

Constructors

Instance Method Summary

Constructor Detail

def self.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.

[View source]

Instance Method Detail

def fetch(key : K, &block : -> V) : V #

[View source]
def write(key : K, value : V) : V #

[View source]