barrel_p2p_map (barrel_p2p v0.1.0)
View SourceSummary
Functions
Alias for remove/2.
Stop the map on THIS node (node-local; not a cluster-wide erase). Also removes any persisted files, so a later new/2 starts fresh rather than reloading stale data. stop_map/1 is synchronous (it waits for the owner to terminate, which closes the log), so the delete runs strictly AFTER the log is closed - no terminate/2 write can race the delete. The file delete is a no-op for a map that did not persist.
Look up a live value (lock-free ETS read).
Live keys (lock-free ETS read).
Start a replicated map named Name on this node. Idempotent.
Put Value under Key. Rejected with {error, invalid_value} if the map's validator rejects the value.
Remove Key.
Subscribe the calling process to {barrel_p2p_map, Name, Event} change events, where Event is {put, Key, Value} or {remove, Key}.
Live key/value pairs (lock-free ETS read).
Types
-type opts() :: #{validator => fun((term()) -> boolean()) | {module(), atom()}, tombstone_ttl_ms => non_neg_integer(), scan_ms => pos_integer(), prune_on_peer_down => boolean(), persist => boolean()}.
Functions
Alias for remove/2.
-spec delete_map(atom()) -> ok.
Stop the map on THIS node (node-local; not a cluster-wide erase). Also removes any persisted files, so a later new/2 starts fresh rather than reloading stale data. stop_map/1 is synchronous (it waits for the owner to terminate, which closes the log), so the delete runs strictly AFTER the log is closed - no terminate/2 write can race the delete. The file delete is a no-op for a map that did not persist.
Look up a live value (lock-free ETS read).
Live keys (lock-free ETS read).
Start a replicated map named Name on this node. Idempotent.
Put Value under Key. Rejected with {error, invalid_value} if the map's validator rejects the value.
Remove Key.
-spec subscribe(atom()) -> ok | {error, no_such_map}.
Subscribe the calling process to {barrel_p2p_map, Name, Event} change events, where Event is {put, Key, Value} or {remove, Key}.
Live key/value pairs (lock-free ETS read).
-spec unsubscribe(atom()) -> ok | {error, no_such_map}.