struct LuckyCache::MemoryStore
- LuckyCache::MemoryStore
- LuckyCache::BaseStore
- Struct
- Value
- Object
Defined in:
lucky_cache/stores/memory_store.crConstructors
Instance Method Summary
-
#delete(key : CacheKey)
Deletes
key
from the cache - #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
-
#flush : Nil
Completely clears all cache keys
-
#read(key : CacheKey) : CacheItem | Nil
Returns the
CacheItem
or nil if thekey
is not found. - #size : Int32
-
#write(key : CacheKey, *, expires_in : Time::Span = LuckyCache.settings.default_duration, &)
Adds the block value to the
cache
.
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 Tfetch(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
Instance Method Detail
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
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
Returns the CacheItem
or nil if the key
is not found.
If the key is found, but the item is expired, it returns nil.
Adds the block value to the cache
. Returns the block value