SuperCache.Cluster.DistributedStore (SuperCache v1.3.0)

Copy Markdown View Source

Shared routing helpers used by all distributed high-level stores (KeyValue, Queue, Stack, Struct).

Write routing

Every write wraps its data in a tuple whose partition value is derived from the store's namespace key (kv_name, queue_name, stack_name, or struct_name). The tuple is handed to Router.route_put!/1 which forwards it to the correct primary node if needed.

Read routing

Reads always go to the local ETS table (eventual consistency by default). Pass read_mode: :primary where strong consistency is required.

Delete routing

Single-key deletes use Router.route_delete_by_key_partition!/2. Pattern deletes use Router.route_delete_match!/2.

Summary

Functions

Read ets_key from the local partition for namespace.

insert_new on the local partition for namespace.

Match-object scan on the local partition for namespace.

take on the local partition for namespace.

Route a delete for ets_key whose partition is derived from namespace.

Route a pattern delete scoped to namespace.

Route a put for a record whose ETS key is ets_key and whose partition is determined by namespace (the store name).

Functions

local_get(ets_key, namespace)

@spec local_get(any(), any()) :: [tuple()]

Read ets_key from the local partition for namespace.

local_insert_new(record, namespace)

@spec local_insert_new(tuple(), any()) :: boolean()

insert_new on the local partition for namespace.

local_match(namespace, pattern)

@spec local_match(any(), tuple()) :: [tuple()]

Match-object scan on the local partition for namespace.

local_take(ets_key, namespace)

@spec local_take(any(), any()) :: [tuple()]

take on the local partition for namespace.

route_delete(ets_key, namespace)

@spec route_delete(any(), any()) :: :ok

Route a delete for ets_key whose partition is derived from namespace.

route_delete_match(namespace, pattern)

@spec route_delete_match(any(), tuple()) :: :ok

Route a pattern delete scoped to namespace.

route_put(ets_key, value)

@spec route_put(any(), any()) :: true

Route a put for a record whose ETS key is ets_key and whose partition is determined by namespace (the store name).

Builds the canonical two-element tuple {ets_key, value} and routes it. The partition position is 0 (the key), so ets_key must embed the namespace so that partition hashing is namespace-scoped.