SiteMaps.Adapters.Memory (site_maps v0.1.0)

Copy Markdown View Source

In-memory storage backed by an Agent, meant for tests.

{:ok, pid} = SiteMaps.Adapters.Memory.start_link()
adapter: {SiteMaps.Adapters.Memory, pid: pid}

Use name: instead of pid: to address a named instance. dump/1 returns the stored objects and history/1 the writes and deletes in the order they happened.

Summary

Functions

Returns a specification to start this module under a supervisor.

Stored objects as a map of key to {binary, meta}.

Writes and deletes in chronological order, as {:write | :delete, key}.

Starts an empty store. Accepts name:.

Types

object()

@type object() :: {binary(), SiteMaps.Adapter.write_meta()}

server()

@type server() :: Agent.agent()

Functions

child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

dump(server)

@spec dump(server()) :: %{required(String.t()) => object()}

Stored objects as a map of key to {binary, meta}.

history(server)

@spec history(server()) :: [{:write | :delete, String.t()}]

Writes and deletes in chronological order, as {:write | :delete, key}.

start_link(opts \\ [])

@spec start_link(keyword()) :: Agent.on_start()

Starts an empty store. Accepts name:.