HareMq.DedupCache
(hare_mq v1.4.0)
Copy Markdown
ETS-backed deduplication cache for RabbitMQ message processing.
Storage
Each cache instance owns a named ETS table (:named_table, :public, :set).
The table name is derived from the registered server name so lookups can go
directly to ETS without passing through the GenServer message queue.
Writes vs reads
add/3(andadd/4) — synchronousGenServer.call. This guarantees that a subsequentis_dup?call on any process will see the entry.is_dup?/2(andis_dup?/3) — reads ETS directly, completely bypassing the GenServer. Concurrent read throughput is not limited by a single process.
Expiry
A 1-second timer runs handle_info(:clear_cache) which calls
:ets.select_delete/2 to remove all rows whose expired_at timestamp is in
the past. This is a C-level operation with no Elixir-side allocation,
keeping the GenServer responsive regardless of cache size.
Named instances
Pass name: to start_link/1 to run isolated caches side-by-side:
{HareMq.DedupCache, name: {:global, :dedup_cache_tenant_a}}Then pass the same name as the third/fourth argument to is_dup?/3 and
add/4. Publishers accept a dedup_cache_name: option.
Summary
Functions
Returns a specification to start this module under a supervisor.
Callback implementation for GenServer.init/1.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Callback implementation for GenServer.init/1.