Fiat.CacheServer.fetch_object

You're seeing just the function fetch_object, go back to Fiat.CacheServer module for more information.

Specs

fetch_object(term()) :: term() | nil

Fetches the cached object for a particular key.

Returns object if it exists in the cache, otherwise returns nil.

Examples

iex> Fiat.CacheServer.cache_object("data", {"code", 2})
iex> Fiat.CacheServer.fetch_object("data")
{"code", 2}

iex> Fiat.CacheServer.fetch_object("data_old")
nil
Link to this function

fetch_object(cache_key, query_fn, expires_in \\ 300)

View Source

Specs

fetch_object(term(), (() -> term()), integer()) :: term()

Fetches the cached object for a particular key. If the cache_key is not present in the cache, it executes the provided query_fn paramter, stores the result in the cache and returns it.

Returns either the cached object or the result of the query_fn parameter.

Examples

iex> Fiat.CacheServer.cache_object("data", :data)
iex> Fiat.CacheServer.fetch_object("data", fn -> :ok end)
:data

iex> Fiat.CacheServer.fetch_object("data", fn -> :ok end)
:ok