Queues, Cache & Events
Typed jobs, queue routing, cache stores, scheduling with pause/resume, and event dispatch.
Queues
Jobs are typed — no any blobs. A job implements the Job trait with a handle method, and dispatch supports dispatch, dispatchSync, chain, delay, onQueue, and onConnection.
Retries use an exponential backoff loop on tokio::spawn workers — no external backoff crate.
Cache
MemoryStore is a lock-guarded HashMap with TTL support. RedisStore is a real implementation behind the opt-in redis feature, with atomic SET NX insert-if-absent and Lua compare-and-delete lock release. Without the feature — or when Redis is unreachable — operations return a typed StoreUnavailable rather than panicking.
Events and listeners
Eventtrait plusListener, whereQueue { enable: true }makes a listener async.dispatchanddispatchAfterResponsecover immediate and post-response dispatch.- Framework events include
JobAttempted { exception }andQueueBusy { connectionName }.
Scheduling
Frequencies cover daily, everyMinute, cron expressions, skipIfStillRunning, and onOneServer. Scheduling is hand-rolled: a 5-field cron parser driven by a 60-second tokio ticker, with no cron crate dependency.
flowchart LR
A["dispatch(job)"] --> B{"Queue::route"}
B --> C["database driver"]
B --> D["redis driver"]
C --> E["worker loop"]
D --> E
E --> F{"handle ok?"}
F -->|yes| G["JobAttempted"]
F -->|no| H["backoff retry"] --> I["failed_jobs"]
Last updated Sep 22, 2026