Usage & Operations Guide
This document centralizes day-to-day usage, programmatic patterns, advanced features, troubleshooting, and performance practices for the Redis Queue plugin.
Table of Contents
Section titled “Table of Contents”- Admin Interface
- REST API Basics
- Programmatic Usage (PHP)
- Advanced Features
- Troubleshooting
- Performance Optimization
- Security Notes
1. Admin Interface
Section titled “1. Admin Interface”Dashboard
Section titled “Dashboard”- Real-time queue statistics
- Manual worker trigger
- Health & processing summary
Job Management
Section titled “Job Management”- Browse, filter, and inspect jobs
- Cancel queued / failed jobs
- View payload, result, and error metadata
Test Interface
Section titled “Test Interface”Quickly create test jobs:
Email Job Example
Type: Single EmailTo: admin@example.comSubject: Test EmailMessage: Testing Redis queue systemImage Processing Example
Operation: Generate ThumbnailsAttachment ID: 123Sizes: thumbnail, medium, largeAPI Sync Example
Operation: WebhookURL: https://httpbin.org/postData: {"test": "message"}2. REST API Basics
Section titled “2. REST API Basics”All endpoints live under: /wp-json/redis-queue/v1/
See docs/worker-rest-api.md for full, authoritative reference including token authentication, scopes, rate limiting, and logging format.
Common endpoints:
POST /jobscreate a jobGET /jobs/{id}fetch job detailsPOST /workers/triggerprocess jobs synchronouslyGET /statsqueue statisticsGET /healthhealth summary
Example: Create a Job
curl -X POST "https://yoursite.com/wp-json/redis-queue/v1/jobs" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "type": "email", "payload": { "to": "user@example.com", "subject": "Hello World", "message": "This is a test email" }, "priority": 10, "queue": "default" }'3. Programmatic Usage (PHP)
Section titled “3. Programmatic Usage (PHP)”Creating & Enqueuing Jobs
Section titled “Creating & Enqueuing Jobs”use Soderlind\RedisQueue\Jobs\Email_Job;
$email_job = new Email_Job([ 'email_type' => 'single', 'to' => 'user@example.com', 'subject' => 'Welcome!', 'message' => 'Welcome to our site!']);
$email_job->set_priority(10);$email_job->set_queue_name('emails');
$job_id = redis_queue()->get_queue_manager()->enqueue( $email_job );Processing Jobs Manually
Section titled “Processing Jobs Manually”use Soderlind\RedisQueue\Workers\Sync_Worker;
$worker = new Sync_Worker( redis_queue()->get_queue_manager(), redis_queue()->get_job_processor());$results = $worker->process_jobs( [ 'default', 'emails' ], 5 );Custom Job Skeleton
Section titled “Custom Job Skeleton”See docs/extending-jobs.md for full guidance.
class Custom_Job extends Abstract_Base_Job { public function get_job_type() { return 'custom_job'; } public function execute() { $data = $this->get_payload(); // Do work return $this->success(['processed' => true]); }}4. Advanced Features
Section titled “4. Advanced Features”Priorities
Section titled “Priorities”0 (highest) → 100 (lowest)
$urgent->set_priority(0);$low->set_priority(90);Delayed Execution
Section titled “Delayed Execution”$job->set_delay_until(time() + 3600); // run in 1 hourMultiple Queues
Section titled “Multiple Queues”$email_job->set_queue_name('emails');$image_job->set_queue_name('images');Error Handling & Retries
Section titled “Error Handling & Retries”- Automatic retries w/ exponential backoff
- Override
should_retry()for granular logic - Failures preserved for inspection
Monitoring Metrics
Section titled “Monitoring Metrics”Surfaces counts, success/failure, durations, backlog depths via admin + /stats endpoint.
5. Troubleshooting
Section titled “5. Troubleshooting”Redis Connection Failed
Section titled “Redis Connection Failed”Error: Redis connection failedFix Checklist:
redis-cli pingreturns PONG- Confirm host/port in settings
- Validate firewall / container network
- Check password auth
Jobs Stuck / Not Processing
Section titled “Jobs Stuck / Not Processing”- Trigger worker manually
- Inspect PHP error logs
- Validate payload JSON structure
- Reduce batch size / memory usage
Memory Exhaustion
Section titled “Memory Exhaustion”Fatal error: Allowed memory size exhaustedMitigations:
- Lower batch size
- Raise PHP memory limit
- Audit custom job memory usage
- Process fewer queues per invocation
Debug Mode
Section titled “Debug Mode”define( 'REDIS_QUEUE_DEBUG', true );define( 'WP_DEBUG_LOG', true );Health Endpoint
Section titled “Health Endpoint”curl -s https://yoursite.com/wp-json/redis-queue/v1/health6. Performance Optimization
Section titled “6. Performance Optimization”Redis Tuning (indicative)
Section titled “Redis Tuning (indicative)”maxmemory-policy allkeys-lrusave 900 1tcp-keepalive 60timeout 300WordPress / PHP
Section titled “WordPress / PHP”define( 'WP_MEMORY_LIMIT', '512M' );ini_set( 'max_execution_time', 300 );Worker Scheduling
Section titled “Worker Scheduling”Cron / supervisor strategies:
* * * * * wp eval "redis_queue()->process_jobs();"Consider external runners for higher throughput.
7. Security Notes
Section titled “7. Security Notes”- REST auth via capability or API token
- Token scopes (
workervsfull) restrict endpoint access - Per-token rate limiting (default 60/min configurable)
- Optional structured request logging with rotation (JSON lines)
- Sanitize + validate payloads; avoid storing secrets raw
- Use encryption or references for sensitive data
For full details see docs/worker-rest-api.md.
Made with ❤️ See README for overview & links.
📦 Source: soderlind/redis-queue · Edit on GitHub