class

PokeAPI::Cache

Inherits Reference < Object

Constructors

new(time_cached : Time::Span = 30.minutes)

Creates a new Cache.

Source

Instance methods

add(key : String, data : String)

Adds data to the cache.

Source
clear

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

Source
disable

Disables the cache.

NOTE: This does not clear the cache.

Source
empty?

Returns true when the cache is empty.

Source
enable

Enables the cache.

Source
get(key : String) : NamedTuple(data: String, cachedTime: Time)

Retrieves data from the cache.

Source
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.

Source
is_enabled?

Returns true if the cache is enabled, otherwise false.

Source
set_cache_time(cache_time : Time::Span)

Sets the time that data is cached to cache_time.

Source