Skip to content

docs: document bucket lifetime and watch semantics - #24

Merged
nmbrone merged 5 commits into
mainfrom
docs/behaviour-notes
Sep 2, 2026
Merged

docs: document bucket lifetime and watch semantics#24
nmbrone merged 5 commits into
mainfrom
docs/behaviour-notes

Conversation

@nmbrone

@nmbrone nmbrone commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Documents behaviour that already exists but was written down nowhere. No code changes.

## Buckets — a bucket's ETS table dies with its owning process and is never repopulated, so a bucket is a cache and not a store. Also that bucket names share one application-wide registry, which matters for anything using Rkv inside a library.

## Watching changes — a notification says that a key changed, not what it changed to, so it has to be followed by a read. Because reads and writes bypass the owning process, the value can move on again before that read lands: you converge on the latest value but cannot reconstruct the sequence of changes. Also that one message arrives per subscription, matching Phoenix.PubSub, so watching both a key and its bucket delivers two.

:ets_options — replaces the defaults rather than merging with them, which is a one-time footgun worth stating. default_ets_options/0 is now documented as the way to extend them, with a verified example. The option docs also now mention the ArgumentError from #23.

Checked with mix docs (no warnings) and the default_ets_options() ++ [:compressed] example was run before being documented.

None of this was written down anywhere: that a bucket's table dies with
its owning process and is not repopulated, that bucket names share one
application-wide namespace, that a notification says a key changed but
not what it changed to, and that :ets_options replaces the defaults
rather than merging with them.

Also documents default_ets_options/0, which is how to extend those
defaults instead of replacing them.
Drops the implementation detail from the new sections — ETS ownership,
the registry, why a value can move on between the message and the read —
and keeps only what a caller has to know.

Also fixes "Unsubsribes" in unwatch_key/2 and unwatch_all/1, and notes
that all/1 returns pairs in no defined order.
- add a link to the docs on hexdocs, which was missing entirely
- lead with the supervision tree instead of the bare start_link, matching
  the moduledoc and the fact that a bucket is a cache
- document {:deleted, bucket, key}, which was absent although delete/2
  has always sent it, and mention unwatch_key/2 and unwatch_all/1
- add parens to IO.puts and use sentence case for headings, so the
  examples match the style the project formats its code with
"Key-value store" is the established term; "storage" reads as the
abstract mass noun. Changes the package description, the moduledoc and
the README together so all three stay in sync.
Replaces the plain documentation link with the badges the ecosystem
uses, so the current version and the docs are reachable from the top of
the README. Also adds a Changelog link to the package metadata, which
only pointed at GitHub before.
@nmbrone
nmbrone merged commit 4b36113 into main Sep 2, 2026
1 check passed
@nmbrone
nmbrone deleted the docs/behaviour-notes branch September 2, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant