CrowdControl.Store.DETS (crowd_control v0.2.0)

Copy Markdown View Source

Disk-backed CrowdControl.Store. Survives a node restart, adds no dependency.

Opt in with:

config :crowd_control, :store,
  {CrowdControl.Store.DETS, path: "/var/lib/crowd_control/sessions.dets"}

Durability

Every write is followed by :dets.sync/1. That is deliberately the slow, correct choice: the whole reason this store exists is to survive an ungraceful death, and a record still sitting in a DETS buffer when the node is SIGKILLed is a leaked container nobody can find. Sessions that write frequently and can tolerate loss should use CrowdControl.Store.ETS instead.

Scope

This is a node-local durable store, not a distributed one. Two nodes pointing at two different DETS files each see only their own sessions — which is why sandbox ownership is enforced by label (CrowdControl.Store.owner_id/0) rather than by store contents. Callers wanting a shared view implement CrowdControl.Store over Ecto or Redis.

Summary

Functions

Returns a specification to start this module under a supervisor.

The default on-disk location when :path is not configured.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

default_path()

@spec default_path() :: Path.t()

The default on-disk location when :path is not configured.