Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [Atomic Locks](#atomic-locks)
- [Managing Locks](#managing-locks)
- [Managing Locks Across Processes](#managing-locks-across-processes)
- [Locks and Function Invocations](#locks-and-function-invocations)
- [Cache Failover](#cache-failover)
- [Adding Custom Cache Drivers](#adding-custom-cache-drivers)
- [Writing the Driver](#writing-the-driver)
Expand Down Expand Up @@ -530,6 +531,27 @@ If you would like to release a lock without respecting its current owner, you ma
Cache::lock('processing')->forceRelease();
```

<a name="locks-and-function-invocations"></a>
### Locks and Function Invocations

The `withoutOverlapping` method provides a simple syntax for executing a given closure while holding an atomic lock, allowing you to ensure only one instance of the closure is running at a given time across your entire infrastructure:

```php
Cache::withoutOverlapping('foo', function () {
// Lock acquired after waiting a maximum of 10 seconds...
});
```

By default, the lock will not be released until the closure finishes executing, and the method will wait up to 10 seconds to acquire the lock. You may customize these values by passing additional arguments to the method:

```php
Cache::withoutOverlapping('foo', function () {
// Lock acquired for 120 seconds after waiting a maximum of 5 seconds...
}, lockSeconds: 120, waitSeconds: 5);
```

If the lock cannot be acquired within the specified wait time, an `Illuminate\Contracts\Cache\LockTimeoutException` will be thrown.

<a name="cache-failover"></a>
## Cache Failover

Expand Down