struct Cache::NullStore(K, V)

Overview

A cache store implementation which doesn't actually store anything. Useful in development and test environments where you don't want caching turned on but need to go through the caching interface.

Defined in:

cache/stores/null_store.cr

Constructors

Instance Method Summary

Instance methods inherited from struct Cache::Store(K, V)

fetch(key : K, *, expires_in = @expires_in, &) fetch, initialize initialize

Constructor methods inherited from struct Cache::Store(K, V)

new new

Constructor Detail

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

[View source]

Instance Method Detail

def fetch(key : K, *, expires_in = @expires_in, &) #
Description copied from struct Cache::Store(K, V)

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. Setting :expires_in will set an expiration time on the cache. All caches support auto-expiring content after a specified number of seconds. This value can be specified as an option to the constructor (in which case all entries will be affected), or it can be supplied to the #fetch or #write method to effect just one entry.

cache = Cache::RedisStore(String, String).new(expires_in: 1.hours)
# Set a lower value for one entry
cache.fetch("today", expires_in: 10.minutes) do
  Time.now.day_of_week
end

[View source]
def read(key : K) #

[View source]
def write(key : K, value : V, *, expires_in = @expires_in) #

[View source]