Minion...:Redis(3pm)
Bestie, welcome to the User Contributed Perl Documentation page for Minion::Backend::Redis β the Minion...:Redis(3pm) manual, aka the Redis backend page for the Minion job queue. β¨ Itβs giving βqueue, but make it Redis,β and weβre keeping every detail exactly where it belongs. π
π NAME π
Minion::Backend::Redis β Redis backend for Minion job queue. π
β¨ SYNOPSIS β¨
No cap, hereβs the setup energy:
use Minion::Backend::Redis;
my $backend = Minion::Backend::Redis->new('redis://127.0.0.1:6379/5');
# Minion
use Minion;
my $minion = Minion->new(Redis => 'redis://127.0.0.1:6379');
# Mojolicious (via Mojolicious::Plugin::Minion)
$self->plugin(Minion => { Redis => 'redis://127.0.0.1:6379/2' });
# Mojolicious::Lite (via Mojolicious::Plugin::Minion)
plugin Minion => { Redis => 'redis://x:s3cret@127.0.0.1:6379' };
π¦ DESCRIPTION π¦
Minion::Backend::Redis is a backend for Minion based on Mojo::Redis. Important vibe check: you need Redis Server (https://redis.io/download) version 2.8.0 or newer to use this backend. No cap. π
β οΈ CAUTION β οΈ
Okay so this is a slightly hackish modification of the original code by Dan Book (https://github.com/Grinnz/Minion-Backend-Redis) to use Mojo::Redis instead of Mojo::Redis2. π
Due to the original code being written against an older Minion version, "history" is currently unimplemented. π«Ά
π₯ PERFORMANCE π₯
You can run examples/minion_bench.pl to get some performance metrics. Literally just run it and soak in the numbers:
Clean start with 10000 jobs
Enqueued 10000 jobs in 52.6373450756073 seconds (189.979/s)
4 workers finished 1000 jobs each in 76.6429250240326 seconds (52.190/s)
4 workers finished 1000 jobs each in 64.2053661346436 seconds (62.300/s)
Requesting job info 100 times
Received job info 100 times in 0.783659934997559 seconds (127.606/s)
Requesting stats 100 times
Received stats 100 times in 0.595925092697144 seconds (167.806/s)
Repairing 100 times
Repaired 100 times in 0.28698992729187 seconds (348.444/s)
Acquiring locks 1000 times
Acquired locks 1000 times in 2.0602331161499 seconds (485.382/s)
Releasing locks 1000 times
Releasing locks 1000 times in 1.19675707817078 seconds (835.591/s)
π ATTRIBUTES π
Minion::Backend::Redis inherits all attributes from Minion::Backend and implements the following new ones. Slay. π
πΈ redis πΈ
my $redis = $backend->redis;
$backend = $backend->redis(Mojo::Redis->new);
Itβs the Mojo::Redis object used to store all data. π
π METHODS π
Okay so Minion::Backend::Redis inherits all methods from Minion::Backend and implements these new ones. Bestie, this is the whole toolkit β every flag, every field, every vibe. Let's go π
β¨ new β¨
my $backend = Minion::Backend::Redis->new;
my $backend = Minion::Backend::Redis->new('redis://x:s3cret@localhost:6379/5');
Construct a new Minion::Backend::Redis object. Fresh backend, fresh energy π«Ά
π£ broadcast π£
my $bool = $backend->broadcast('some_command');
my $bool = $backend->broadcast('some_command', [@args]);
my $bool = $backend->broadcast('some_command', [@args], [$id1, $id2, $id3]);
Broadcast a remote control command to one or more workers. It's giving group-chat announcement energy, but for workers β¨
π dequeue π
my $job_info = $backend->dequeue($worker_id, 0.5);
my $job_info = $backend->dequeue($worker_id, 0.5, {queues => ['important']});
Wait a given amount of time in seconds for a job, dequeue it, and transition it from "inactive" to "active" state β or return "undef" if the queues were empty. No cap, it's literally waiting for the moment π
These options are currently available:
idβid => '10023'β dequeue a specific job.queuesβqueues => ['important']β one or more queues to dequeue jobs from, defaults to"default".
These fields are currently available:
argsβargs => ['foo', 'bar']β job arguments.idβid => '10023'β job ID.retriesβretries => 3β number of times job has been retried.taskβtask => 'foo'β task name.
πΈ enqueue πΈ
my $job_id = $backend->enqueue('foo');
my $job_id = $backend->enqueue(foo => [@args]);
my $job_id = $backend->enqueue(foo => [@args] => {priority => 1});
Enqueue a new job with "inactive" state. New job, who dis? π
These options are currently available:
attemptsβattempts => 25β number of times performing this job will be attempted, with a delay based on"backoff" in Minionafter the first attempt, defaults to 1.delayβdelay => 10β delay job for this many seconds (from now).notesβnotes => {foo => 'bar', baz => [1, 2, 3]}β hash reference with arbitrary metadata for this job.parentsβparents => [$id1, $id2, $id3]β one or more existing jobs this job depends on, and that need to have transitioned to the state"finished"before it can be processed.priorityβpriority => 5β job priority, defaults to 0. Jobs with a higher priority get performed first.queueβqueue => 'important'β queue to put job in, defaults to"default".
π fail_job π
my $bool = $backend->fail_job($job_id, $retries);
my $bool = $backend->fail_job($job_id, $retries, 'Something went wrong!');
my $bool = $backend->fail_job(
$job_id, $retries, {msg => 'Something went wrong!'});
Transition from "active" to "failed" state, and if there are attempts remaining, transition back to "inactive" with an exponentially increasing delay based on "backoff" in Minion. It ate, but not in the good way π
π¦ finish_job π¦
my $bool = $backend->finish_job($job_id, $retries);
my $bool = $backend->finish_job($job_id, $retries, 'All went well!');
my $bool = $backend->finish_job($job_id, $retries, {msg => 'All went well!'});
Transition from "active" to "finished" state. Slay, job well done β¨
π§ history π§
my $history = $backend->history;
Get history information for job queue. Unimplemented for now. It's giving "coming soon" energy, bestie π«Ά
These fields are currently available:
dailyβdaily => [{epoch => 12345, finished_jobs => 95, failed_jobs => 2}, ...]β hourly counts for processed jobs from the past day.
π list_jobs π
my $results = $backend->list_jobs($offset, $limit);
my $results = $backend->list_jobs($offset, $limit, {state => 'inactive'});
Returns the information about jobs in batches. Look at all these little jobbies π
# Check job state
my $results = $backend->list_jobs(0, 1, {ids => [$job_id]});
my $state = $results->{jobs}[0]{state};
# Get job result
my $results = $backend->list_jobs(0, 1, {ids => [$job_id]});
my $result = $results->{jobs}[0]{result};
These options are currently available:
idsβids => ['23', '24']β list only jobs with these ids.queueβqueue => 'important'β list only jobs in this queue.stateβstate => 'inactive'β list only jobs in this state.taskβtask => 'test'β list only jobs for this task.
These fields are currently available:
argsβargs => ['foo', 'bar']β job arguments.attemptsβattempts => 25β number of times performing this job will be attempted.childrenβchildren => ['10026', '10027', '10028']β jobs depending on this job.createdβcreated => 784111777β epoch time job was created.delayedβdelayed => 784111777β epoch time job was delayed to.finishedβfinished => 784111777β epoch time job was finished.notesβnotes => {foo => 'bar', baz => [1, 2, 3]}β hash reference with arbitrary metadata for this job.parentsβparents => ['10023', '10024', '10025']β jobs this job depends on.priorityβpriority => 3β job priority.queueβqueue => 'important'β queue name.resultβresult => 'All went well!'β job result.retriedβretried => 784111777β epoch time job has been retried.retriesβretries => 3β number of times job has been retried.startedβstarted => 784111777β epoch time job was started.stateβstate => 'inactive'β current job state, usually"active","failed","finished"or"inactive".taskβtask => 'foo'β task name.workerβworker => '154'β id of worker that is processing the job.
π list_locks π
my $results = $backend->list_locks($offset, $limit);
my $results = $backend->list_locks($offset, $limit, {names => ['foo']});
Returns information about locks in batches. Lock lore, unlocked πβ¨
# Get the total number of results (without limit)
my $num = $backend->list_locks(0, 100, {names => ['bar']})->{total};
# Check expiration time
my $results = $backend->list_locks(0, 1, {names => ['foo']});
my $expires = $results->{locks}[0]{expires};
These options are currently available:
namesβnames => ['foo', 'bar']β list only locks with these names.
These fields are currently available:
expiresβexpires => 784111777β epoch time this lock will expire.nameβname => 'foo'β lock name.
π«Ά list_workers π«Ά
my $results = $backend->list_workers($offset, $limit);
my $results = $backend->list_workers($offset, $limit, {ids => [23]});
Returns information about workers in batches. Worker appreciation post π
# Check worker host
my $results = $backend->list_workers(0, 1, {ids => [$worker_id]});
my $host = $results->{workers}[0]{host};
These options are currently available:
idsβids => ['23', '24']β list only workers with these ids.
These fields are currently available:
hostβhost => 'localhost'β worker host.jobsβjobs => ['10023', '10024', '10025', '10029']β ids of jobs the worker is currently processing.notifiedβnotified => 784111777β epoch time worker sent the last heartbeat.pidβpid => 12345β process id of worker.startedβstarted => 784111777β epoch time worker was started.statusβstatus => {queues => ['default', 'important']}β hash reference with whatever status information the worker would like to share.
π lock π
my $bool = $backend->lock('foo', 3600);
my $bool = $backend->lock('foo', 3600, {limit => 20});
Try to acquire a named lock that will expire automatically after the given amount of time in seconds. Secure the bag, bestie π
These options are currently available:
limitβlimit => 20β number of shared locks with the same name that can be active at the same time, defaults to 1.
π note π
my $bool = $backend->note($job_id, foo => 'bar');
Change a metadata field for a job. Little note, big main character energy β¨
π‘ receive π‘
my $commands = $backend->receive($worker_id);
Receive remote control commands for worker. Incoming messages, iykyk π«Ά
πͺ© register_worker πͺ©
my $worker_id = $backend->register_worker;
my $worker_id = $backend->register_worker($worker_id);
my $worker_id = $backend->register_worker(
$worker_id, {status => {queues => ['default', 'important']}});
Register worker or send heartbeat to show that this worker is still alive. "I'm still standing" β worker edition π
These options are currently available:
statusβstatus => {queues => ['default', 'important']}β hash reference with whatever status information the worker would like to share.
ποΈ remove_job ποΈ
my $bool = $backend->remove_job($job_id);
Remove "failed", "finished" or "inactive" job from queue. Bye-bye, jobbie π
π οΈ repair π οΈ
$backend->repair;
Repair worker registry and job queue if necessary. Glow-up for your backend π§
π reset π
$backend->reset;
Reset job queue. Fresh start, no cap β¨
π‘ retry_job π‘
my $bool = $backend->retry_job($job_id, $retries);
my $bool = $backend->retry_job($job_id, $retries, {delay => 10});
Transition job back to "inactive" state, already "inactive" jobs may also be retried to change options. Run it back, bestie π
These options are currently available:
attemptsβattempts => 25β number of times performing this job will be attempted.delayβdelay => 10β delay job for this many seconds (from now).priorityβpriority => 5β job priority.queueβqueue => 'important'β queue to put job in.
π stats π
my $stats = $backend->stats;
Get statistics for jobs and workers. Numbers are kinda iconic ngl π
These fields are currently available:
active_jobsβactive_jobs => 100β number of jobs in"active"state.active_workersβactive_workers => 100β number of workers that are currently processing a job.delayed_jobsβdelayed_jobs => 100β number of jobs in"inactive"state that are scheduled to run at specific time in the future. Note that this field is EXPERIMENTAL and might change without warning!enqueued_jobsβenqueued_jobs => 100000β rough estimate of how many jobs have ever been enqueued. Note that this field is EXPERIMENTAL and might change without warning!failed_jobsβfailed_jobs => 100β number of jobs in"failed"state.finished_jobsβfinished_jobs => 100β number of jobs in"finished"state.inactive_jobsβinactive_jobs => 100β number of jobs in"inactive"state.inactive_workersβinactive_workers => 100β number of workers that are currently not processing a job.uptimeβuptime => 1000β uptime in seconds.
π unlock π
my $bool = $backend->unlock('foo');
Release a named lock. Free at last, free at last π¦
π unregister_worker π
$backend->unregister_worker($worker_id);
Unregister worker. Leaving the group chat, respectfully π
π BUGS π
Report any issues on the public bugtracker.
π«Ά AUTHOR π«Ά
Lowkey the whole thing is by Dan Book β <dbook@cpan.org> if you ever wanna slide into his inbox (respectfully tho π). Icon behaviour, no cap.
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2017 by Dan Book.
It's free software, bestie, licensed under:
The Artistic License 2.0 (GPL Compatible)
So yes β it's giving freedom, it's giving open source, it's giving legally-blessed reusing energy β¨ (just, like, read the license fr fr, don't just vibe off the summary π ).
π SEE ALSO π
Minionβ the actual job queue system this whole thing plugs into. Main character energy. Go read that one next, iykyk πMojo::Redisβ the async Redis driver doing the heavy lifting underneath, our beloved supporting cast π
and that's a wrap on this page, bestie π¦π«Ά tysm for reading all the way down β this doc came to you from perl v5.42.2, dated 2026-02-15, and it's genuinely iconic that you made it to the footer. slay, go build something ππβ¨
π¦ where this page comes from
- alpine 3.24: perl-minion-backend-redis-doc 0.003-r1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms