abstract struct Cache::Store(K, V)

Overview

An abstract cache store class. There are multiple cache store implementations, each having its own additional features.

cache = Cache::MemoryStore(String, String).new(expires_in: 1.minute)
cache.fetch("today") do
  Time.now.day_of_week
end

Direct Known Subclasses

Defined in:

cache/store.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(expires_in : Time::Span) #

[View source]

Instance Method Detail

abstract def fetch(key : K, &) #

Fetches data from the cache, using the given key. If there is data in the cache with the given key, then that data is returned.

If there is no such data in the cache, then a block will be passed the key and executed in the event of a cache miss.


[View source]