struct

LuckyCache::MemoryStore

Inherits LuckyCache::BaseStore < Struct < Value < Object

Constructors

Instance methods

delete(key : CacheKey)

Deletes key from the cache

Source
fetch(key : CacheKey, *, as : Array(T).class, expires_in : Time::Span = LuckyCache.settings.default_duration, &) forall T

If the CacheItem exists, it will map the Array(Cacheable) in to Array(T). If no item is found, write the block value and return the block value

Source
fetch(key : CacheKey, *, as : T.class, expires_in : Time::Span = LuckyCache.settings.default_duration, &) forall T

If the CacheItem exists, it will cast the Cacheable in to T. If no item is found, write the block value and return the block value

Source
flush

Completely clears all cache keys

Source
read(key : CacheKey) : CacheItem | Nil

Returns the CacheItem or nil if the key is not found. If the key is found, but the item is expired, remove it and return nil.

Source
size

The total number of items in the cache.

Source
write(key : CacheKey, *, expires_in : Time::Span = LuckyCache.settings.default_duration, &)

Adds the block value to the cache. Returns the block value

Source