# `SuperCache.Queue`
[🔗](https://github.com/ohhi-vn/super_cache/blob/main/lib/api/queue.ex#L10)

Named FIFO queues backed by SuperCache ETS partitions.

Works transparently in both **local** and **distributed** modes — the
mode is determined by the `:cluster` option passed to `SuperCache.start!/1`.

In distributed mode, structural mutations (`add`, `out`, `get_all`) are
routed to the partition's primary node.  Reads (`peak`, `count`) default
to the local replica and accept `:read_mode` for stronger consistency.

## Example

    alias SuperCache.Queue

    Queue.add("jobs", :compress)
    Queue.add("jobs", :upload)
    Queue.count("jobs")          # => 2
    Queue.peak("jobs")           # => :compress
    Queue.out("jobs")            # => :compress
    Queue.get_all("jobs")        # => [:upload]

# `add`

```elixir
@spec add(any(), any()) :: true
```

Enqueue `value` into `queue_name`. Creates the queue if it does not exist.

# `count`

```elixir
@spec count(
  any(),
  keyword()
) :: non_neg_integer()
```

Return the number of items.

## Options

- `:read_mode` — `:local` (default), `:primary`, or `:quorum`.

# `get_all`

```elixir
@spec get_all(any()) :: list()
```

Drain all items (oldest first). Returns `[]` for an empty queue.

# `out`

```elixir
@spec out(any(), any()) :: any()
```

Dequeue and return the front value. Returns `default` (`nil`) when empty.

# `peak`

```elixir
@spec peak(any(), any(), keyword()) :: any()
```

Peek at the front value without removing it.

## Options

- `:read_mode` — `:local` (default), `:primary`, or `:quorum`.

---

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