# `BullMQ.Keys`
[🔗](https://github.com/taskforcesh/bullmq/blob/v2.2.3/lib/bullmq/keys.ex#L1)

Redis key generation for BullMQ queues.

This module generates consistent Redis keys following the BullMQ naming convention.
All keys follow the pattern: `{prefix}:{queue_name}:{key_type}`.

The default prefix is "bull" for compatibility with the Node.js BullMQ library.

# `queue_context`

```elixir
@type queue_context() :: %{prefix: String.t(), name: String.t()}
```

Queue key context containing prefix and name

# `active`

```elixir
@spec active(queue_context()) :: String.t()
```

Key for the active jobs list

# `all_queue_keys`

```elixir
@spec all_queue_keys(queue_context()) :: [String.t()]
```

Returns all queue-level keys for obliteration/cleanup.

# `base`

```elixir
@spec base(queue_context()) :: String.t()
```

Returns the base key for a queue.

## Examples

    iex> ctx = BullMQ.Keys.new("my_queue")
    iex> BullMQ.Keys.base(ctx)
    "bull:my_queue"

# `completed`

```elixir
@spec completed(queue_context()) :: String.t()
```

Key for the completed jobs sorted set

# `context`

```elixir
@spec context(String.t()) :: queue_context()
```

# `context`

```elixir
@spec context(String.t(), String.t()) :: queue_context()
```

Creates a new queue context for key generation.

## Examples

    iex> BullMQ.Keys.context("bull", "my_queue")
    %{prefix: "bull", name: "my_queue"}

    iex> BullMQ.Keys.context("my_queue")
    %{prefix: "bull", name: "my_queue"}

# `dedup`

```elixir
@spec dedup(queue_context(), String.t()) :: String.t()
```

Key for deduplication

# `delayed`

```elixir
@spec delayed(queue_context()) :: String.t()
```

Key for the delayed jobs sorted set

# `dependencies`

```elixir
@spec dependencies(queue_context(), String.t()) :: String.t()
```

Key for a job's dependencies set (child jobs)

# `events`

```elixir
@spec events(queue_context()) :: String.t()
```

Key for the events stream

# `failed`

```elixir
@spec failed(queue_context()) :: String.t()
```

Key for the failed jobs sorted set

# `get`

```elixir
@spec get(queue_context(), String.t()) :: String.t()
```

Get a key by name (dynamic key lookup)

# `id`

```elixir
@spec id(queue_context()) :: String.t()
```

Key for the job ID counter

# `job`

```elixir
@spec job(queue_context(), String.t()) :: String.t()
```

Key for a specific job hash

# `job_dependencies`

```elixir
@spec job_dependencies(queue_context(), String.t()) :: String.t()
```

Key for a job's dependencies set (alias)

# `job_failed`

```elixir
@spec job_failed(queue_context(), String.t()) :: String.t()
```

Key for a job's failed children hash

# `job_lock`

```elixir
@spec job_lock(queue_context(), String.t()) :: String.t()
```

Key for a job's lock (alias for lock/2)

# `job_logs`

```elixir
@spec job_logs(queue_context(), String.t()) :: String.t()
```

Key for a job's logs list (alias for logs/2)

# `job_processed`

```elixir
@spec job_processed(queue_context(), String.t()) :: String.t()
```

Key for a job's processed children hash (alias)

# `job_scheduler`

```elixir
@spec job_scheduler(queue_context()) :: String.t()
```

Key for the job schedulers

# `job_unsuccessful`

```elixir
@spec job_unsuccessful(queue_context(), String.t()) :: String.t()
```

Key for a job's unsuccessful children sorted set

# `key`

```elixir
@spec key(queue_context()) :: String.t()
```

Returns the base key for a queue (without suffix).

## Examples

    iex> ctx = BullMQ.Keys.new("my_queue")
    iex> BullMQ.Keys.key(ctx)
    "bull:my_queue"

# `key_prefix`

```elixir
@spec key_prefix(queue_context()) :: String.t()
```

Returns the key prefix for building job keys (with trailing colon).

This matches the Node.js `queueKeys['']` which is used to build job keys
by concatenating with the job ID: `prefix:queuename:jobid`

## Examples

    iex> ctx = BullMQ.Keys.new("my_queue")
    iex> BullMQ.Keys.key_prefix(ctx)
    "bull:my_queue:"

# `limiter`

```elixir
@spec limiter(queue_context()) :: String.t()
```

Key for the rate limiter

# `lock`

```elixir
@spec lock(queue_context(), String.t()) :: String.t()
```

Key for a job's lock

# `logs`

```elixir
@spec logs(queue_context(), String.t()) :: String.t()
```

Key for a job's logs list

# `marker`

```elixir
@spec marker(queue_context()) :: String.t()
```

Key for the marker sorted set (for blocking operations)

# `meta`

```elixir
@spec meta(queue_context()) :: String.t()
```

Key for the queue metadata hash

# `metrics`

```elixir
@spec metrics(queue_context(), String.t() | :completed | :failed) :: String.t()
```

Key for the metrics hash

# `new`

```elixir
@spec new(String.t(), keyword()) :: queue_context()
```

Creates a new queue context for key generation.

Alias for `context/1` and `context/2` with keyword options.

## Examples

    iex> BullMQ.Keys.new("my_queue")
    %{prefix: "bull", name: "my_queue"}

    iex> BullMQ.Keys.new("my_queue", prefix: "myapp")
    %{prefix: "myapp", name: "my_queue"}

# `parse_job_id`

```elixir
@spec parse_job_id(String.t()) :: String.t()
```

Parses a job key to extract the job ID.

## Examples

    iex> BullMQ.Keys.parse_job_id("bull:my_queue:123")
    "123"

# `parse_job_key`

```elixir
@spec parse_job_key(String.t()) :: {:ok, map()} | {:error, :invalid_key}
```

Extracts queue name and job ID from a full job key.

## Examples

    iex> BullMQ.Keys.parse_job_key("bull:my_queue:123")
    {:ok, %{prefix: "bull", queue: "my_queue", job_id: "123"}}

# `paused`

```elixir
@spec paused(queue_context()) :: String.t()
```

Key for the paused jobs list

# `pc`

```elixir
@spec pc(queue_context()) :: String.t()
```

Key for the priority counter

# `prioritized`

```elixir
@spec prioritized(queue_context()) :: String.t()
```

Key for the prioritized jobs sorted set

# `processed`

```elixir
@spec processed(queue_context(), String.t()) :: String.t()
```

Key for a job's processed children hash

# `repeat`

```elixir
@spec repeat(queue_context()) :: String.t()
```

Key for the repeatable jobs hash

# `scan_pattern`

```elixir
@spec scan_pattern(queue_context()) :: String.t()
```

Returns all keys matching the queue pattern for scanning.

# `schedulers`

```elixir
@spec schedulers(queue_context()) :: String.t()
```

Key for the job schedulers (short form)

# `stalled`

```elixir
@spec stalled(queue_context()) :: String.t()
```

Key for the stalled jobs set

# `stalled_check`

```elixir
@spec stalled_check(queue_context()) :: String.t()
```

Key for the stalled check marker

# `wait`

```elixir
@spec wait(queue_context()) :: String.t()
```

Key for the waiting jobs list

# `waiting_children`

```elixir
@spec waiting_children(queue_context()) :: String.t()
```

Key for the waiting-children jobs sorted set

---

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