RpcLoadBalancer.LoadBalancer.IndexRegistry (rpc_load_balancer v0.3.4)

Copy Markdown View Source

Assigns unique integer indices to arbitrary keys for a given cache.

Uses Cache.PersistentTerm for key-to-index mappings and :atomics for a monotonic next-index counter per cache. Indices are zero-based and never reused.

Summary

Functions

adapter_options()

cache_adapter()

cache_name()

child_spec(_)

delete(key)

get(key)

get_index(cache_name, key)

@spec get_index(atom(), term()) :: non_neg_integer() | nil

Read the index for a key without telemetry overhead.

Goes directly to the configured cache adapter, skipping the :telemetry.span/3-wrapped Cache.get/1. Returns nil when the key has never been registered.

Companion to get_or_register/2 — use this when callers must not allocate a new index on miss.

get_or_create(key, fnc)

get_or_register(cache_name, key)

@spec get_or_register(atom(), term()) :: non_neg_integer()

init_counter(cache_name)

@spec init_counter(atom()) :: :ok

put(key, ttl \\ nil, value)