CouncilEx.Reliability.Redis (CouncilEx v0.1.0)

Copy Markdown View Source

Redis-backed CouncilEx.Reliability store. Multi-replica safe.

Same scoring math as CouncilEx.Reliability.ETS (Laplace-smoothed beta mean), same bucket-key shape ((member_id, phash2(features))). Counts live in a Redis hash per bucket; HINCRBY makes increments atomic across replicas.

Setup

Add :redix to your deps:

{:council_ex, "~> 0.12"},
{:redix, "~> 1.5"}

Start a Redix connection in your app supervisor and tell council_ex about it:

children = [
  {Redix, name: :council_ex_redix, host: "localhost"},
  # ...
]

config :council_ex,
  :reliability_store,
  CouncilEx.Reliability.Redis

config :council_ex, CouncilEx.Reliability.Redis,
  conn: :council_ex_redix,
  prefix: "council_ex:reliability"

Both :conn and :prefix default to :council_ex_redix and "council_ex:reliability" respectively.

Failure mode

If Redis is unreachable, record/3 returns {:error, reason} and score/2 returns nil (cold-start fallback). Callers continue with equal-weight aggregation rather than crashing.

Summary

Functions

Wipe all reliability keys under the configured prefix. Use with care.

Functions

reset()

@spec reset() :: :ok | {:error, term()}

Wipe all reliability keys under the configured prefix. Use with care.