class PokeAPI::Cache

Defined in:

pokeapi/cache.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(time_cached : Time::Span = 30.minutes) #

Creates a new Cache.


[View source]

Instance Method Detail

def add(key : String, data : String) #

Adds data to the cache.


[View source]
def clear : Bool #

Clears the cache. true is returned if the cache was cleared successfully, otherwise false.


[View source]
def disable #

Disables the cache.

NOTE This does not clear the cache.


[View source]
def empty? : Bool #

Returns true when the cache is empty.


[View source]
def enable #

Enables the cache.


[View source]
def get(key : String) : NamedTuple(data: String, cachedTime: Time) #

Retrieves data from the cache.


[View source]
def has_key?(key : String) : Bool #

Checks if cache contains key. Returns true is key is in cache and the value has not been cached for more than time_cached. false is returned if key doesn't exist in the cache or if the cached data is out-dated. Out-dated data gets deleted before false is returned.


[View source]
def is_enabled? : Bool #

Returns true if the cache is enabled, otherwise false.


[View source]
def set_cache_time(cache_time : Time::Span) #

Sets the time that data is cached to cache_time.


[View source]