News

Cache Concurrency Limiting in Laravel 12.53.0

Published
Cache Concurrency Limiting in Laravel 12.53.0 image

Release updates

Never miss a Laravel release

Get an email whenever a new Laravel release lands.

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.

Sponsored

laravelcloud logo
Laravel Cloud

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

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article