# `SuperCache.Cluster.DistributedStore`
[🔗](https://github.com/ohhi-vn/super_cache/blob/main/lib/cluster/distributed_store.ex#L1)

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`.

# `local_get`

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

Read `ets_key` from the local partition for `namespace`.

# `local_insert_new`

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

insert_new on the local partition for `namespace`.

# `local_match`

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

Match-object scan on the local partition for `namespace`.

# `local_take`

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

take on the local partition for `namespace`.

# `route_delete`

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

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

# `route_delete_match`

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

Route a pattern delete scoped to `namespace`.

# `route_put`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
