4,000 emails/month for free | Mailtrap sends real emails now!

Cache Concurrency Limiting in Laravel 12.53.0

Last updated on by

Cache Concurrency Limiting in Laravel 12.53.0 image

Laravel v12.53.0 introduces Cache::funnel() for concurrency limiting backed by any lock-capable cache driver, adds named argument support to event dispatching and broadcasting, and extends PostgreSQL full-text search with pre-computed tsvector column support.

Key highlights include:

  • Cache::funnel() for cache-backed concurrency limiting
  • Named arguments in event dispatching and broadcasting
  • whereFullText vector option for pre-computed tsvector columns (PostgreSQL)
  • buildMorphMapFromModels() accepts array keys
  • php artisan down can refresh maintenance mode options in-place
  • Event macros on schedule groups

What's New

Cache::funnel() Concurrency Limiting

Cache::funnel() brings concurrency limiting to any cache driver that supports atomic locks — including the array, file, database, and Redis drivers. Previously, concurrency limiting in Laravel relied on Redis::funnel(), which required a Redis connection. This new facade method works across drivers using the same lock primitives already available in the cache layer.

Cache::funnel('payment-processing')
->limit(3)
->releaseAfter(60)
->then(
fn() => processPayment(),
fn() => 'Currently at capacity'
);
  • limit(int $slots) — max concurrent operations allowed
  • releaseAfter(int $seconds) — how long to hold the lock before auto-release
  • block(int $timeout) — how long to wait for a slot before giving up
  • then(callable $success, callable $failure) — runs the success callback when a slot is acquired, or the failure callback when blocked

If the driver doesn't support locks, a BadMethodCallException is thrown. When a blocking timeout expires without a failure callback, a LimiterTimeoutException is raised.

Pull Request: #58439

Named Arguments in Event Dispatching and Broadcasting

The Dispatchable trait now supports named arguments when calling dispatch() and broadcast() on event classes. The trait previously used func_get_args() internally, which discarded argument names. Switching to variadic syntax allows named arguments to pass through to the event constructor.

// Before — positional arguments only
event(new UserSubscribed($user, $plan, $metadata));
 
// After — named arguments now work
UserSubscribed::dispatch(
user: $user,
plan: $plan,
metadata: ['source' => 'checkout'],
);

This is consistent with how job dispatching already handles named arguments. Existing positional-argument calls continue to work without changes.

Pull Request: #58913

PostgreSQL Full-Text Search with Pre-Computed tsvector Columns

whereFullText() gains a vector option for PostgreSQL that treats the column as a pre-computed tsvector instead of wrapping it in to_tsvector() on every query. This is useful when you maintain a dedicated tsvector column — often indexed with GIN — to avoid the overhead of recomputing the vector at query time.

// Without vector option — wraps column in to_tsvector()
$query->whereFullText('body', $term, ['language' => 'english']);
 
// With vector option — uses the column directly
$query->whereFullText('search_vector', $term, [
'vector' => true,
'language' => 'english',
'mode' => 'websearch',
]);
 
// Also works with multiple tsvector columns
$query->whereFullText(['tsv_title', 'tsv_body'], $term, ['vector' => true]);

Pull Request: #58893

buildMorphMapFromModels() Accepts Array Keys

buildMorphMapFromModels() now accepts any array key type — string or integer — when building a morph map from model classes. Previously the parameter only accepted list-style integer-keyed arrays, which prevented using custom string aliases:

// Custom string aliases now work
Relation::buildMorphMapFromModels([
'post' => Post::class,
'video' => Video::class,
]);

Pull Request: #58891

Maintenance Mode down Refreshes Options In-Place

php artisan down can now be re-run while the application is already in maintenance mode to update options — such as the secret, message, or retry value — without taking the site back up first. Previously, you had to run php artisan up before changing maintenance mode settings.

# Put site in maintenance mode
php artisan down --secret="my-secret"
 
# Update the secret without bringing the site back up
php artisan down --secret="new-secret"

Pull Request: #58918

Event Macros on Schedule Groups

Scheduled command Event macros can now be applied to schedule groups, allowing shared behavior to be registered once and applied to all commands in a group rather than on each entry individually.

Pull Request: #58926

Bug Fixes and Improvements

Database:

  • Fix cross-database null-safe equals operations (#58962)
  • Rollback lingering PDO state before retrying on commit deadlock (#58906)

Queue & Jobs:

  • Fix model serialization in queue jobs (#58939)
  • Fix RetryCommand not working for SQS FIFO queues (#58936)
  • Ensure oldest_pending displays correctly in queue:monitor (#58952)

HTTP & Caching:

  • Fix race condition when creating real-time facade cache file (#58947)
  • Fix RequestException summarizing for Guzzle streamed responses (#58909)
  • Cache now supports serializable class values (#58911)

Testing:

  • Show all mismatched values in assertSessionHasAll failure output (#58946)

Mail:

  • Change text alignment from left to start for better RTL language support (#58935)

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
Jump24 - UK Laravel Agency

Laravel Developers that Click into Place. Never outsourced. Never offshored. Always exceptional.

Visit Jump24 - UK Laravel Agency
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Tinkerwell logo

Tinkerwell

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

Tinkerwell
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
PhpStorm logo

PhpStorm

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

PhpStorm
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
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
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

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

Shift
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
Lucky Media logo

Lucky Media

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

Lucky Media
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

The latest

View all →
Filament turns five in style! image

Filament turns five in style!

Read article
Cache Concurrency Limiting in Laravel 12.53.0 image

Cache Concurrency Limiting in Laravel 12.53.0

Read article
Stop Failing APIs from Killing Your Queue — Fuse for Laravel image

Stop Failing APIs from Killing Your Queue — Fuse for Laravel

Read article
Blaze: An Optimized Blade Template Compiler for Laravel image

Blaze: An Optimized Blade Template Compiler for Laravel

Read article
Chief: Run Claude Code on Large Projects with Task-Based Workflows image

Chief: Run Claude Code on Large Projects with Task-Based Workflows

Read article
Laravel OpenAPI CLI: Generate Artisan Commands from Your API Spec image

Laravel OpenAPI CLI: Generate Artisan Commands from Your API Spec

Read article