FakeRiak.SimpleStore (fake_riak v0.2.2)

Copy Markdown View Source

The shared in-memory key-value store, a single GenServer backing every endpoint.

It holds two independent keyspaces so both the bucketed and bucketless protocols can share one process:

The bucketed space models Riak's siblings: each key holds a list of values, so get/2 replies {:ok, values} with a non-empty list. put/4 takes a merge mode — :append adds the value as a new sibling (byte-identical values are deduplicated, as real Riak does), while :replace collapses the key to a single value, the way resolving with a vector clock does. put/3 defaults to :replace. The bucketless space stays strictly last-write-wins: its get/1 replies {:ok, value} with a single value.

In both spaces get replies {:error, reason} when absent, and put/delete reply :ok (with delete returning {:error, reason} when the key is absent). The public functions run in the caller's connection process, so when --verbose is set they log each operation, attributed to that connection's protocol.

Summary

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

delete(key)

delete(bucket, key)

get(key)

get(bucket, key)

init(_)

Callback implementation for GenServer.init/1.

keys(bucket)

put(key, value)

put(bucket, key, value, mode \\ :replace)

start_link(_)