Laravel Cloud is here! Zero-config managed infrastructure for Laravel apps. Deploy now.

Redis Cluster Support for Queues in Laravel 13.5.0

Published on by

Redis Cluster Support for Queues in Laravel 13.5.0 image

Never Miss a Laravel Release 🚀

Sign up and get an email with each new Laravel release

Laravel v13.5.0 adds first-class Redis Cluster support for the queue driver and concurrency limiter, fixing CROSSSLOT errors on AWS ElastiCache Serverless and other Redis Cluster deployments. It also completes #[Delay] attribute coverage for queued mailables, adds Controller Middleware attribute inheritance, expands enum support across manager classes, and includes a number of bug fixes.

  • First-class Redis Cluster support for Queue and ConcurrencyLimiter
  • #[Delay] attribute now works on queued mailables
  • Controller Middleware attributes are inherited by child controllers
  • Enum support expanded across Cache, Mail, Auth, and other manager drivers
  • Closure values accepted in updateOrCreate and firstOrNew
  • New Cache::handleUnserializableClassUsing() hook for detecting broken cache values
  • Fix for ShouldBeUniqueUntilProcessing jobs releasing locks they don't own

What's New

First-Class Redis Cluster Support for Queue and ConcurrencyLimiter

When using AWS ElastiCache Serverless (Valkey) or any Redis Cluster deployment, Laravel's Redis queue and ConcurrencyLimiter previously failed with CROSSSLOT errors. The queue's Lua scripts operate across multiple keys — queues:default, queues:default:reserved, and queues:default:notify — that hash to different cluster slots, which Redis Cluster prohibits in a single command.

Laravel now automatically wraps queue names in Redis hash tags when the connection is a cluster, ensuring all related keys hash to the same slot:

queues:{default} → slot for "default"
queues:{default}:delayed → slot for "default"
queues:{default}:reserved → slot for "default"
queues:{default}:notify → slot for "default"

Different queues ({emails}, {notifications}) still distribute across the cluster naturally. The public getQueue() method is unchanged, so existing integrations that consume queue names continue to see the same format as before, while Redis operations themselves use cluster-safe keys. Non-cluster users are unaffected.

The ConcurrencyLimiter receives the same treatment — slot keys are now wrapped in hash tags on cluster connections, so the mget Lua script no longer crosses slots.

On phpredis 5.3.2 and newer, the PhpRedis cluster connector also gains ACL auth support and max_retries, backoff_algorithm, backoff_base, and backoff_cap options to improve compatibility with ElastiCache Serverless scaling behavior.

Pull Request: #59533 by @timmylindh

#[Delay] Attribute Support on Queued Mailables

The #[Delay] attribute support added across queued event listeners, jobs, and notifications in v13.4.0 now applies to queued mailables too. Previously, mailables only checked the $delay property and ignored the attribute entirely.

use Illuminate\Queue\Attributes\Delay;
 
#[Delay(30)]
class WelcomeEmail extends Mailable implements ShouldQueue
{
// Now correctly delayed by 30 seconds when queued
}

The $delay property still takes precedence when explicitly set, matching the behavior of the other dispatchers.

Pull Request: #59580 by @sumaiazaman

Controller Middleware Attribute Inheritance

The #[Middleware] attribute on a base controller is now inherited by child controllers. Previously, child controllers ignored middleware attributes defined on their parent, requiring duplication across each class.

use Illuminate\Routing\Attributes\Middleware;
 
#[Middleware('auth')]
#[Middleware('log:api')]
abstract class AdminBaseController extends Controller
{
// Common admin logic
}
 
class AdminController extends AdminBaseController
{
public function index()
{
// Inherits 'auth' and 'log:api' middleware from the parent
}
}

Attributes are collected in parent-to-child order, consistent with how PHP resolves class hierarchies.

Pull Request: #59597 by @niduranga

Enum Support Expanded Across Manager Classes

Enum support has been added to several manager classes that were previously missing it:

CacheManager — store(), driver(), memo(), forgetDriver(), purge(), and setDefaultDriver() now accept a UnitEnum:

enum CacheStore: string
{
case Redis = 'redis';
case Array = 'array';
}
 
Cache::store(CacheStore::Redis)->put('key', 'value');

MailManager — mailer(), driver(), and purge() now accept enums.

AuthManager — guard(), shouldUse(), and setDefaultDriver() now accept enums.

Laravel also added enum support to the base Manager::driver() method, extending the same pattern to other manager classes that inherit from it.

This continues the enum-support wave that already covered QueueManager, LogManager, DatabaseManager, FilesystemManager, RedisManager, and BroadcastManager.

Pull Requests: #59637, #59645, #59646, #59659 by @yousefkadah and @scabarcas17

Closure Values in updateOrCreate and firstOrNew

updateOrCreate and firstOrNew now accept a Closure for the $values argument, completing the lazy-evaluation pattern introduced in v13.x for firstOrCreate and createOrFirst. This allows you to defer expensive operations — like geocoding or API calls — until you know the record actually needs to be created or updated:

$location = Location::updateOrCreate(
['address' => $address],
fn () => ['coordinates' => Geocoder::resolve($address)],
);

The closure is called exactly once per method call. On firstOrNew, the closure is never invoked when the record already exists.

Pull Request: #59647 by @yousefkadah

Detect Unserializable Cache Values

A new Cache::handleUnserializableClassUsing() hook lets you register a callback that runs when a cache value deserializes to __PHP_Incomplete_Class — which can happen when the serializable_classes config is in use and a class is missing from the allow-list.

Cache::handleUnserializableClassUsing(function (string $key, ?string $class): void {
if (app()->isProduction()) {
Log::warning("Cache hit [{$key}] returned unserializable class [{$class}]");
return;
}
 
throw new RuntimeException("Cache hit [{$key}] returned unserializable class [{$class}]");
});

No handler is registered by default, so this is purely opt-in with no behavior changes for existing applications.

Pull Request: #59630 by @jackbayliss

Other Fixes and Improvements

Queue:

  • Fixed ShouldBeUniqueUntilProcessing job retries releasing locks they don't own (#59567 by @kohlerdominik)

Redis:

  • Normalized phpredis SSL context options for single and cluster connections (#59569 by @timmylindh)

Auth:

  • Fixed redirectUsersTo() overwriting the redirectGuestsTo() callback (#59633 by @timmylindh)
  • Fixed a loose comparison false positive in NotPwnedVerifier with magic hash passwords (#59644 by @scabarcas17)

Testing:

  • Memoized the result of TestCase::withoutBootingFramework() to avoid redundant work (#59610 by @cosmastech)

Other:

  • Fixed a custom driver binding bug in Manager classes (#59614 by @ollieread)
  • Added spatie/fork to Composer suggestions for concurrency support (#59660 by @jnoordsij)
  • Moved the Scope interface @template from method-level to class-level to fix an LSP violation (#59675 by @kayw-geek)

References

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
SerpApi logo

SerpApi

Access real-time search engine results through a simple API—no more scraping headaches! Use it for AI applications, SEO tools, product research, travel information, and more

SerpApi
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud

The latest

View all →
Laravel Installer Now Returns JSON When Running Inside an AI Agent image

Laravel Installer Now Returns JSON When Running Inside an AI Agent

Read article
Queue-Wide Inspection Methods in Laravel 13.8.0 image

Queue-Wide Inspection Methods in Laravel 13.8.0

Read article
Verifiable Audit Logging with Laravel Chronicle image

Verifiable Audit Logging with Laravel Chronicle

Read article
Ship AI with Laravel: Search Entire PDFs with Zero Search Logic image

Ship AI with Laravel: Search Entire PDFs with Zero Search Logic

Read article
Personalized Content Delivery System: Building an AI-powered recommendation engine with Laravel and MongoDB image

Personalized Content Delivery System: Building an AI-powered recommendation engine with Laravel and MongoDB

Read article
Laravel Brain: Visualize Your Application's Request Lifecycle image

Laravel Brain: Visualize Your Application's Request Lifecycle

Read article