BullMQ.Keys (BullMQ v1.0.1)
View SourceRedis 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.
Summary
Types
Queue key context containing prefix and name
Functions
Key for the active jobs list
Returns all queue-level keys for obliteration/cleanup.
Returns the base key for a queue.
Key for the completed jobs sorted set
Creates a new queue context for key generation.
Key for deduplication
Key for the delayed jobs sorted set
Key for a job's dependencies set (child jobs)
Key for the events stream
Key for the failed jobs sorted set
Get a key by name (dynamic key lookup)
Key for the job ID counter
Key for a specific job hash
Key for a job's dependencies set (alias)
Key for a job's failed children hash
Key for a job's lock (alias for lock/2)
Key for a job's logs list (alias for logs/2)
Key for a job's processed children hash (alias)
Key for the job schedulers
Key for a job's unsuccessful children sorted set
Returns the base key for a queue (without suffix).
Returns the key prefix for building job keys (with trailing colon).
Key for the rate limiter
Key for a job's lock
Key for a job's logs list
Key for the marker sorted set (for blocking operations)
Key for the queue metadata hash
Key for the metrics hash
Creates a new queue context for key generation.
Parses a job key to extract the job ID.
Extracts queue name and job ID from a full job key.
Key for the paused jobs list
Key for the priority counter
Key for the prioritized jobs sorted set
Key for a job's processed children hash
Key for the repeatable jobs hash
Returns all keys matching the queue pattern for scanning.
Key for the job schedulers (short form)
Key for the stalled jobs set
Key for the stalled check marker
Key for the waiting jobs list
Key for the waiting-children jobs sorted set
Types
Functions
@spec active(queue_context()) :: String.t()
Key for the active jobs list
@spec all_queue_keys(queue_context()) :: [String.t()]
Returns all queue-level keys for obliteration/cleanup.
@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"
@spec completed(queue_context()) :: String.t()
Key for the completed jobs sorted set
@spec context(String.t()) :: queue_context()
@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"}
@spec dedup(queue_context(), String.t()) :: String.t()
Key for deduplication
@spec delayed(queue_context()) :: String.t()
Key for the delayed jobs sorted set
@spec dependencies(queue_context(), String.t()) :: String.t()
Key for a job's dependencies set (child jobs)
@spec events(queue_context()) :: String.t()
Key for the events stream
@spec failed(queue_context()) :: String.t()
Key for the failed jobs sorted set
@spec get(queue_context(), String.t()) :: String.t()
Get a key by name (dynamic key lookup)
@spec id(queue_context()) :: String.t()
Key for the job ID counter
@spec job(queue_context(), String.t()) :: String.t()
Key for a specific job hash
@spec job_dependencies(queue_context(), String.t()) :: String.t()
Key for a job's dependencies set (alias)
@spec job_failed(queue_context(), String.t()) :: String.t()
Key for a job's failed children hash
@spec job_lock(queue_context(), String.t()) :: String.t()
Key for a job's lock (alias for lock/2)
@spec job_logs(queue_context(), String.t()) :: String.t()
Key for a job's logs list (alias for logs/2)
@spec job_processed(queue_context(), String.t()) :: String.t()
Key for a job's processed children hash (alias)
@spec job_scheduler(queue_context()) :: String.t()
Key for the job schedulers
@spec job_unsuccessful(queue_context(), String.t()) :: String.t()
Key for a job's unsuccessful children sorted set
@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"
@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:"
@spec limiter(queue_context()) :: String.t()
Key for the rate limiter
@spec lock(queue_context(), String.t()) :: String.t()
Key for a job's lock
@spec logs(queue_context(), String.t()) :: String.t()
Key for a job's logs list
@spec marker(queue_context()) :: String.t()
Key for the marker sorted set (for blocking operations)
@spec meta(queue_context()) :: String.t()
Key for the queue metadata hash
@spec metrics(queue_context(), String.t() | :completed | :failed) :: String.t()
Key for the metrics hash
@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"}
Parses a job key to extract the job ID.
Examples
iex> BullMQ.Keys.parse_job_id("bull:my_queue:123")
"123"
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"}}
@spec paused(queue_context()) :: String.t()
Key for the paused jobs list
@spec pc(queue_context()) :: String.t()
Key for the priority counter
@spec prioritized(queue_context()) :: String.t()
Key for the prioritized jobs sorted set
@spec processed(queue_context(), String.t()) :: String.t()
Key for a job's processed children hash
@spec repeat(queue_context()) :: String.t()
Key for the repeatable jobs hash
@spec scan_pattern(queue_context()) :: String.t()
Returns all keys matching the queue pattern for scanning.
@spec schedulers(queue_context()) :: String.t()
Key for the job schedulers (short form)
@spec stalled(queue_context()) :: String.t()
Key for the stalled jobs set
@spec stalled_check(queue_context()) :: String.t()
Key for the stalled check marker
@spec wait(queue_context()) :: String.t()
Key for the waiting jobs list
@spec waiting_children(queue_context()) :: String.t()
Key for the waiting-children jobs sorted set