ActiveMemory v0.7 — query in-memory data by attributes, not just keys (now with TTL + crash resilience)
ActiveMemory is a typed, attribute-queryable in-memory store for ETS and Mnesia. Where a key/value cache answers “what’s the value for this key?”, ActiveMemory answers the questions a cache can’t:
SessionStore.select(%{user_id: user_id, active?: true}) StaffStore.select(match(:role == "admin" and :last_login < cutoff)) TokenStore.withdraw(%{value: submitted_token}) # atomic take-once: exactly one caller winsYou define a
Tablewith named attributes and get typed structs queryable by any combination of fields — no cache keys to design, no match specs to hand-write. v0.7 adds the safety rails for real workloads:
- TTL / record expiry — expired records are never returned, and a background sweep reclaims the memory. Ideal for one-time tokens, 2FA codes, and magic links.
- Crash resilience — an ETS heir process preserves your table when a Store crashes; the restarted Store reclaims it with data intact. Zero config.
- Atomic
withdraw/1— fetch-and-delete as a single atomic operation (:ets.select_delete/2/ Mnesia transaction).- ActiveRepo — manage many tables (mixing ETS and Mnesia) from one supervised process. Named so it won’t collide with your
Ecto.Repo.Hex: https://hex.pm/packages/active_memory Docs: https://hexdocs.pm/active_memory GitHub: https://github.com/SullysMustyRuby/active_memory
Feedback and contributions welcome!
Read next API Management Console - runtime route toggling for Phoenix apps
