Expander v0.0.1 Expander.Cache.Adapters.Local.Storage.Memory View Source
In-memory storage driver used by the [Expander.Adapters.Local] module.
The urls are stored in memory and won’t persist once your application is stopped.
Link to this section Summary
Functions
List all values in cache
Delete all keys from cache
Get a value from cache given the key
Set a key value in cache
Starts the server
Stops the server
Link to this section Functions
List all values in cache.
Examples
iex> {:ok, conn} = GenServer.start_link(Memory, [])
iex> Memory.set(conn, "moski", "doski")
{:ok, "OK"}
iex> Memory.all(conn)
%{"moski" => "doski"}
Delete all keys from cache.
Examples
iex> {:ok, conn} = GenServer.start_link(Memory, [])
iex> Memory.set(conn, "key1", "val1")
iex> Memory.set(conn, "key2", "val2")
iex> Memory.set(conn, "key3", "val3")
iex> Memory.all(conn) |> Enum.count()
3
iex> Memory.delete_all(conn)
iex> Memory.all(conn) |> Enum.count()
0
Get a value from cache given the key.
Examples
iex> {:ok, conn} = GenServer.start_link(Memory, [])
iex> Memory.set(conn, "moski", "doski")
iex> Memory.all(conn) |> Enum.count()
1
iex> Memory.get(conn, "moski")
{:ok, "doski"}
Set a key value in cache.
Examples
iex> {:ok, conn} = GenServer.start_link(Memory, [])
iex> Memory.set(conn, "key1", "val1")
iex> Memory.set(conn, "key2", "val2")
iex> Memory.set(conn, "key3", "val3")
iex> Memory.all(conn) |> Enum.count()
3
Starts the server
Stops the server