struct LuckyCache::MemoryStore

Defined in:

lucky_cache/stores/memory_store.cr

Constructors

Instance Method Summary

Instance methods inherited from struct LuckyCache::BaseStore

delete(key : CacheKey) delete, fetch(key : CacheKey, *, as : Array(T).class, expires_in : Time::Span = LuckyCache.settings.default_duration, &) forall T
fetch(key : CacheKey, *, as : T.class, expires_in : Time::Span = LuckyCache.settings.default_duration, &) forall T
fetch
, flush : Nil flush, initialize initialize, read(key : CacheKey) : CacheItem | Nil read, size : Int32 size, write(key : CacheKey, *, expires_in : Time::Span = LuckyCache.settings.default_duration, &) write

Constructor methods inherited from struct LuckyCache::BaseStore

new new

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def delete(key : CacheKey) #

Deletes key from the cache


[View source]
def 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(Cachable) in to Array(T). If no item is found, write the block value and return the block value


[View source]
def fetch(key : CacheKey, *, as : T.class, expires_in : Time::Span = LuckyCache.settings.default_duration, &) forall T #

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


[View source]
def flush : Nil #

Completely clears all cache keys


[View source]
def 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, it returns nil.


[View source]
def size : Int32 #

[View source]
def write(key : CacheKey, *, expires_in : Time::Span = LuckyCache.settings.default_duration, &) #

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


[View source]