OptionalblockingConnection: RedisConnectionOptionalblockingResolves once a close has been initiated. Owned by the backend (it owns the underlying connection(s)).
The raw blocking Redis client (a dedicated connection used for the
blocking waitForJob primitive), if this backend was created with one.
Redis-specific escape hatch; not part of IQueueBackend.
The raw Redis client. Redis-specific escape hatch (used e.g. by
Queue.client); not part of IQueueBackend.
The detected datastore flavour (redis, dragonfly, valkey, …).
Redis-specific escape hatch; not part of IQueueBackend.
The concrete Redis keys for this queue (wait, active, events, …).
Smallest meaningful block timeout (seconds) given the blocking connection's capabilities.
The queue's fully-qualified name ("<prefix>:<queue>"). This is the
cross-backend logical identifier (e.g. used as a flow parent reference).
The detected Redis server version. Redis-specific escape hatch; not part of IQueueBackend.
Atomically inserts a whole flow (tree) of jobs that may span multiple
queues, returning one [error, idOrCode] tuple per entry in the same
order they were provided. For the Redis adapter this is a single MULTI
transaction; another backend would use a single SQL transaction.
Each entry is self-describing (it carries its own queue prefix and
queueName), so the operation does not need to be bound to a single
queue's key map.
Adds a single job to the queue, routing it to the correct initial state (wait / delayed / prioritized / waiting-children) based on its options.
The backend uses its own connection — callers never pass one in.
Adds many jobs to the queue in a single, efficient operation.
How the insert is batched (a Redis pipeline, a single multi-row SQL
INSERT, a transaction, …) is entirely an implementation detail of the
backend; the contract only requires that all jobs are added and their ids
returned in order.
The generated ids, in the same order as entries.
Low-level Redis adapter helper: queues/executes a single job insert on the provided client or transaction (pipeline/multi). This is the only place that needs a connection handle; the public addJob / addJobs operations obtain it from the backend itself.
Kept public (but outside IQueueBackend) so that flow producers can batch inserts across queues onto a shared transaction.
Appends a row to a job's log, optionally trimming old entries.
OptionalkeepLogs: numberThe total number of log entries.
Change delay of a delayed job.
Reschedules a delayed job by setting a new delay from the current time. For example, calling changeDelay(5000) will reschedule the job to execute 5000 milliseconds (5 seconds) from now, regardless of the original delay.
the ID of the job to change the delay for.
milliseconds from now when the job should be processed.
delay in milliseconds.
Changes the priority (and optionally lifo) of a waiting job.
Remove jobs in a specific state.
Id jobs from the deleted records.
Clears a job's logs, optionally keeping the most recent keepLogs rows.
OptionalkeepLogs: numberBuilds the Redis client name ("<prefix>:<base64(queue)><suffix>"), used
for CLIENT SETNAME and worker/queue discovery via CLIENT LIST.
Closes the backend and its underlying connection(s).
The dedicated blocking connection (if any) is closed first so that an
in-flight blocking command (e.g. bzpopmin) is interrupted before the
main connection is closed.
Unconditionally deletes a deduplication key.
The number of keys removed.
Forcibly disconnects the backend's underlying connection(s).
Interrupts the in-flight blocking wait by disconnecting the dedicated blocking connection. No-op if there is none.
Removes waiting (and optionally delayed) jobs from the queue.
Extends the lock of a single active job.
Optionalclient: IRedisClient | IRedisTransactionExtends the lock of several active jobs at once.
The ids of the jobs whose lock could not be extended.
Returns a sibling backend bound to a different queue that shares this
backend's connection(s). Used by FlowProducer to operate on the
many queues that a flow may span over a single connection. The sibling
does not own the connection, so its close/disconnect are no-ops.
Optionalprefix: stringReturns the raw worker/client list(s) for the queue's datastore. For the
Redis adapter this is CLIENT LIST (one string per cluster node, or a
single string otherwise). Backends with no notion of connected clients
may return an empty array.
Returns the job id currently holding the given deduplication key, if any.
Returns a job's children dependencies (processed/unprocessed/ignored/failed).
Returns the raw ignored-children failures map (child key → reason).
Returns the stored data for a job, or undefined if it is missing.
Fetches job ids and their job hashes for the provided states in a single
script, skipping ids whose job hash is missing (for example the deprecated
wait list marker or jobs removed after their id was read). Each returned
entry is a [jobId, jobHashFields] tuple grouped per requested type.
Returns the raw stored metadata hash for a job scheduler.
Returns the number of registered job schedulers.
Returns a range of scheduler keys with their next-run scores, flattened as
[key, score, key, score, …].
Returns the raw processed-children map (child key → serialized value).
Reads the entire queue metadata hash.
Reads a single queue metadata field.
Reads several queue metadata fields at once, in order.
Returns the ttl (ms) of the current rate-limit window.
OptionalmaxJobs: numberOptionalmaxJobs: numberReturns whether a queue metadata field exists.
Returns whether a job has finished and (optionally) its result.
Checks whether a job with the given id is present in the provided queue state.
Returns whether an id corresponds to a registered job scheduler.
Returns whether the queue has reached its concurrency limit.
Moves a job back from Active to Wait. This script is used when a job has been manually rate limited and needs to be moved back to wait from active status.
Job id
Looks for unlocked jobs in the active queue.
The job was being worked on, but the worker process died and it failed to renew the lock. We call these jobs 'stalled'. This is the most common case. We resolve these by moving them back to wait to be re-processed. To prevent jobs from cycling endlessly between active and wait, (e.g. if the job handler keeps crashing), we limit the number stalled job recoveries to settings.maxStalledCount.
Atomically moves the next eligible job from wait/prioritized to active, returning its data (or the delay/rate-limit signals when none is ready).
Optionalname: stringMoves an active job to the completed state and, optionally, fetches the next job to process.
The next job data tuple when fetchNext is set, plus the
finishedOn timestamp that was recorded.
Moves a job to the delayed state, scheduling it to run after delay ms.
Moves an active job to the failed state and, optionally, fetches the next job to process.
OptionalfieldsToUpdate: Record<string, any>The next job data tuple when fetchNext is set, plus the
finishedOn timestamp that was recorded.
OptionalfieldsToUpdate: Record<string, any>Move parent job to waiting-children state.
true if job is successfully moved, false if there are pending dependencies.
Optionalopts: MoveToWaitingChildrenOptsIrreversibly destroys the queue and all of its contents.
A cursor; 0 when obliteration is complete.
Paginate a set or hash keys.
options to define the pagination behaviour
Parses a Redis flow child key ("<prefix>:<queue>:<id>") into its
components. Inverse of toKey.
Pauses or resumes the whole queue.
Promotes a single delayed job so it can be processed as soon as possible.
Promotes up to count delayed jobs back to wait.
A cursor; 0 when there are no more jobs to promote.
Publishes a custom event to the queue's event stream.
The id of the appended event entry.
Blocks (up to blockTimeout ms) reading the queue's event stream for
entries newer than id, returning the raw stream entries (or a falsy value
on timeout). For the Redis adapter this is an XREAD ... BLOCK.
Re-establishes the dedicated blocking connection after an interrupt.
Removes a job and (optionally) its children.
1 if removed, 0 if it (or a dependency) was locked.
Removes the child→parent dependency for a not-yet-finished child.
true if the dependency existed and was removed.
Removes the deprecated priority helper key.
The number of keys removed.
Removes orphaned job keys that exist in the datastore but are not referenced by any queue state set.
The total number of orphaned jobs removed.
Removes one or more queue metadata fields.
Removes the rate-limit key.
The number of keys removed.
Removes all unprocessed children of a job.
Attempts to reprocess a job
The job to reprocess
The expected job state. If the job is not found on the provided state, then it's not reprocessed. Supported states: 'failed', 'completed'
A promise that resolves when the job has been successfully moved to the wait queue.
Moves up to count finished jobs of the given state back to wait.
A cursor; 0 when there are no more jobs to move.
Retries a failed/active job immediately by pushing it back to wait.
Sets a human-readable name on the underlying connection (CLIENT SETNAME). Unsupported-command and shutdown errors are swallowed.
Sets one or more queue metadata fields.
Sets the global rate-limit window for the next jobs.
Builds a namespaced Redis sub-key of the given type
("<prefix>:<queue>:<type>").
Trims the event stream to an approximate maximum length.
The number of entries removed.
OptionalproducerId: stringUpdates a job's progress and emits the corresponding event.
Blocks (up to blockTimeout seconds) until the queue signals that a new
job may be available, returning the next "block-until" timestamp.
For the Redis adapter this is a BZPOPMIN on the marker sorted set using
the adapter's own dedicated blocking connection; other adapters may
implement it via LISTEN/NOTIFY, change-data-capture or polling.
The marker member/score on success, or null on timeout.
Resolves once the backend's underlying connection(s) are ready.
IQueueBackend
Database-agnostic contract describing every high-level operation that the Queue, Worker and Job classes need in order to function. The goal of this interface is to express the queue semantics ("move job to active", "extend lock", "promote job", …) independently of the underlying datastore.
Built-in implementations currently include the Redis adapter (RedisQueueBackend) and the PostgreSQL adapter. Both fulfil the same operations over different datastores without requiring any change to
Queue,WorkerorJob.The method names and signatures intentionally mirror the existing
RedisQueueBackendclass so that the Redis adapter is a near drop-in implementation. Operations that used to be performed via direct datastore commands scattered across the three classes (queue metadata, job getters, the blocking "wait for next job" primitive, …) have been promoted into this interface so that the three classes never need to talk to the datastore directly.Remarks
Low-level, Redis-specific helpers (Lua KEYS/ARGV builders, error-code mapping,
runCommand, …) are deliberately not part of this contract. They remain private implementation details of the Redis adapter.The interface intentionally exposes no connection or transaction type: a concrete adapter owns its connection(s). For example, the Redis adapter is built from a context that provides an IRedisClient (plus a dedicated blocking client for IQueueBackend.waitForJob), so callers never thread a connection or transaction through an operation.