-
-
Notifications
You must be signed in to change notification settings - Fork 14
feat: Add RefreshableLock interface for long-running task support
#335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
651fbb8
Add RefreshableLock interface for long-running task support
binaryfire f4a2258
Fix refresh(0) semantics and inline Lua scripts
binaryfire 4bc5414
Throw InvalidArgumentException for refresh() with non-positive TTL
binaryfire 9e1c091
Merge remote-tracking branch 'origin/main' into feature/lock-refresh
binaryfire 562ce1b
Move Lua scripts from RedisLock to LuaScripts class
binaryfire d14895f
Fix ArrayLock to validate parameters before ownership check
binaryfire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Hypervel\Cache\Contracts; | ||
|
|
||
| use InvalidArgumentException; | ||
|
|
||
| /** | ||
| * A lock that supports refreshing its TTL and inspecting remaining lifetime. | ||
| * | ||
| * Not all lock drivers can implement this interface atomically. Drivers that | ||
| * cannot guarantee atomic refresh operations (like CacheLock) should not | ||
| * implement this interface. | ||
| */ | ||
| interface RefreshableLock extends Lock | ||
| { | ||
| /** | ||
| * Refresh the lock's TTL if still owned by this process. | ||
| * | ||
| * This operation is atomic - if the lock has been released or acquired | ||
| * by another process, this will return false without modifying anything. | ||
| * | ||
| * When called without arguments on a permanent lock (one acquired with | ||
| * a TTL of 0), this is a no-op that returns true since there's no TTL | ||
| * to refresh. | ||
| * | ||
| * @param null|int $seconds Seconds to set the TTL to (null = use original TTL from construction) | ||
| * @return bool True if the lock was refreshed (or is permanent), false if not owned or expired | ||
| * | ||
| * @throws InvalidArgumentException If $seconds is explicitly provided and is not positive | ||
| */ | ||
| public function refresh(?int $seconds = null): bool; | ||
|
|
||
| /** | ||
| * Get the number of seconds until the lock expires. | ||
| * | ||
| * @return null|float Seconds remaining, or null if lock doesn't exist or has no expiry | ||
| */ | ||
| public function getRemainingLifetime(): ?float; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.