View Source ExKits.Cache.Storage behaviour (ex_kits v0.2.7)
A cache storage module that provides a simple interface for storing and retrieving key-value pairs.
Examples
iex> storage = ExKits.Cache.Storage.new([])
iex> ExKits.Cache.Storage.put(storage, :key, "value", [])
:ok
iex> ExKits.Cache.Storage.get(storage, :key)
"value"
Summary
Functions
delete a key-value pair from the cache storage
get the value of a key from the cache storage
put a key-value pair into the cache storage
Types
@type k() :: term()
@type opts() :: Keyword.t()
@type put_opts() :: [{:ttl, pos_integer() | :infinity}]
@type t() :: struct()
@type v() :: term() | nil
Callbacks
Functions
delete a key-value pair from the cache storage
Examples
iex> storage = ExKits.Storage.ETS.new([])
iex> ExKits.Cache.Storage.del(storage, :key)
:ok
get the value of a key from the cache storage
Examples
iex> storage = ExKits.Storage.ETS.new([])
iex> ExKits.Cache.Storage.get(storage, :key)
nil
put a key-value pair into the cache storage
Examples
iex> storage = ExKits.Storage.ETS.new([])
iex> ExKits.Cache.Storage.put(storage, :key, "value", [])
:ok