Laravel Cloud 来了!为 Laravel 应用提供零配置的托管基础​​设施。 立即部署

Redis Cluster Support for Queues in Laravel 13.5.0

发布日期 经过

Redis Cluster Support for Queues in Laravel 13.5.0 image

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 updateOrCreatefirstOrNew
  • 新的 Cache::handleUnserializableClassUsing() hook for detecting broken cache values
  • 修复 ShouldBeUniqueUntilProcessing jobs releasing locks they don't own

什么是新的

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 , 和 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.

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 , 和 backoff_cap options to improve compatibility with ElastiCache Serverless scaling behavior.

拉取请求: #59533 经过 @timmylindh

#[Delay] Attribute Support on Queued Mailables

#[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.

使用 Illuminate\Queue\Attributes\Delay ;
#[ Delay 30 )]
班级 WelcomeEmail 延伸 可邮寄 实现 应该排队
{
// Now correctly delayed by 30 seconds when queued
}

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

拉取请求: #59580 经过 @sumaiazaman

Controller Middleware Attribute Inheritance

#[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.

使用 Illuminate\Routing\Attributes\Middleware ;
#[ 中间件 ‘授权’ )]
#[ 中间件 'log:api' )]
抽象的 班级 AdminBaseController 延伸 控制器
{
// Common admin logic
}
班级 AdminController 延伸 AdminBaseController
{
民众 功能 指数 ()
{
// Inherits 'auth' and 'log:api' middleware from the parent
}
}

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

拉取请求: #59597 经过 @niduranga

Enum Support Expanded Across Manager Classes

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

缓存管理器store() , driver() , memo() , forgetDriver() , purge() , 和 setDefaultDriver() now accept a UnitEnum :

枚举 CacheStore : 细绳
{
案件 雷迪斯 = 'redis' ;
案件 大批 = '大批' ;
}
缓存 :: 店铺 CacheStore :: 雷迪斯 -> '钥匙' , '价值' (英文):

MailManagermailer() , driver() , 和 purge() now accept enums.

AuthManagerguard() , shouldUse() , 和 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 , 和 BroadcastManager

拉取请求: #59637 , #59645 , #59646 , #59659 经过 @yousefkadah@scabarcas17

Closure Values in updateOrCreatefirstOrNew

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

位置 = 地点 :: 更新或创建
[ '地址' => $address],
fn () => [ 坐标 => 地理编码器 :: 解决 ($address)],
(英文):

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

拉取请求: #59647 经过 @yousefkadah

Detect Unserializable Cache Values

新的 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.

缓存 :: handleUnserializableClassUsing 功能 细绳 $key, ?细绳 $class) : 空白 {
如果 应用程序 () -> 是生产 ()){
日志 :: 警告 "Cache hit [{ $键 }] returned unserializable class [{ $class }]" (英文):
返回 ;
}
新的 运行时异常 "Cache hit [{ $键 }] returned unserializable class [{ $class }]" (英文):
});

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

拉取请求: #59630 经过 @jackbayliss

其他修复和改进

Queue:

  • 固定的 ShouldBeUniqueUntilProcessing job retries releasing locks they don't own ( #59567 经过 @kohlerdominik

Redis:

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

授权:

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

测试:

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

其他:

  • Fixed a custom driver binding bug in Manager classes ( #59614 经过 @ollieread
  • 额外 spatie/fork to Composer suggestions for concurrency support ( #59660 经过 @jnoordsij
  • Moved the Scope 界面 @template from method-level to class-level to fix an LSP violation ( #59675 经过 @kayw极客

参考

保罗·雷德蒙德照片

Laravel News 特约撰稿人。全栈 Web 开发人员兼作家。

归档于:
立方体

Laravel 时事通讯

加入超过 4 万名开发者的行列,不错过任何新的技巧、教程等内容。

图像
Jump24 - 英国 Laravel 代理机构

Laravel 开发人员,精通技术,绝不外包,绝不离岸外包,始终卓越。

访问 Jump24 - 英国 Laravel 代理机构
Tinkerwell 徽标

廷克威尔

Laravel 开发者必备的代码运行器。可在本地和生产环境中体验 AI、自动补全和即时反馈功能。

廷克威尔
几天内即可获得 Laravel 代码审查徽标的专家指导

几天内即可获得 Laravel 代码审查方面的专家指导

专家级代码审查!两位拥有 10 年以上 Laravel 开发经验的开发者将为您提供清晰、实用的反馈,帮助团队构建更优质的应用程序。

几天内即可获得 Laravel 代码审查方面的专家指导
PhpStorm 标志

PhpStorm

首选的 PHP IDE,对 Laravel 及其生态系统提供广泛的开箱即用支持。

PhpStorm
Laravel Cloud 标志

Laravel 云

轻松创建和管理服务器,并在几秒钟内部署 Laravel 应用程序。

Laravel 云
了解 Softtech 的标志

了解软科技

Acquaint Softtech 提供 AI 就绪的 Laravel 开发人员,48 小时内即可上手,每月费用为 3000 美元,没有冗长的销售流程,并提供 100% 退款保证。

了解软科技
Kirschbaum 标志

樱桃树

提供创新和稳定性,确保您的Web应用程序取得成功。

樱桃树
Shift 标志

转移

还在运行旧版本的 Laravel?立即实现 Laravel 自动升级和代码现代化,让您的应用程序保持最新状态。

转移
鱼叉:新一代时间跟踪和发票标志

Harpoon:新一代时间跟踪和发票系统

新一代时间跟踪和计费软件,帮助您的机构规划和预测盈利的未来。

Harpoon:新一代时间跟踪和发票系统
Lucky Media 标志

幸运传媒

Get Lucky Now——拥有十余年经验的 Laravel 开发理想之选!

幸运传媒
SaaSykit:Laravel SaaS 入门套件徽标

SaaSykit:Laravel SaaS 入门套件

SaaSykit 是一个多租户 Laravel SaaS 入门套件,包含运行现代 SaaS 所需的所有功能,例如支付、美观的结账界面、管理面板、用户仪表盘、身份验证、现成组件、统计数据、博客、文档等等。

SaaSykit:Laravel SaaS 入门套件
MongoDB 徽标

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB
Spatie Shares Their Coding Guidelines as AI Skills image

Spatie Shares Their Coding Guidelines as AI Skills

阅读文章
AI Generative Engine Optimization for Laravel image

AI Generative Engine Optimization for Laravel

阅读文章
Attach PDFs Directly to Mailables in laravel-pdf 2.6.0 image

Attach PDFs Directly to Mailables in laravel-pdf 2.6.0

阅读文章
Composer 2.9.6 Fixes Two Perforce Command Injection Vulnerabilities image

Composer 2.9.6 Fixes Two Perforce Command Injection Vulnerabilities

阅读文章
Ship AI with Laravel: Your AI Agent Has Amnesia. Let's Fix It. image

Ship AI with Laravel: Your AI Agent Has Amnesia. Let's Fix It.

阅读文章
Redis Cluster Support for Queues in Laravel 13.5.0 image

Redis Cluster Support for Queues in Laravel 13.5.0

阅读文章