# `SuperCache.Stack`
[🔗](https://github.com/ohhi-vn/super_cache/blob/main/lib/api/stack.ex#L7)

Named LIFO stacks 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 (`push`, `pop`, `get_all`) are
routed to the partition's primary node.

## Example

    alias SuperCache.Stack

    Stack.push("history", :page_a)
    Stack.push("history", :page_b)
    Stack.pop("history")          # => :page_b
    Stack.get_all("history")      # => [:page_a]

# `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 top-first. Returns `[]` for an empty stack.

# `pop`

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

Pop and return the top value. Returns `default` (`nil`) when empty.

# `push`

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

Push `value` onto `stack_name`. Creates the stack if it does not exist.

---

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