Skip to content
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

[11.x] Add function to validate if a lock is owned by the current owner. #49249

Closed
wants to merge 4 commits into from

Conversation

Joostb
Copy link
Contributor

@Joostb Joostb commented Dec 5, 2023

This pr adds a public function isOwner to the Cache/Lock.php class and the Contracts/Cache/Lock class. This can be used to determine if a restored lock is owned by the current owner. Currently it is not possible to determine if a restoredLock is owned by the given owner, except when releasing it.

We ran into a problem when we wanted to validate on the queue if we still had the lock on a specific key. We pass the $owner to the job, and can currently release the lock using restoreLock($key, $owner)->release(), but we have no way of validating whether the lock is still viable (without releasing it).

@taylorotwell taylorotwell marked this pull request as draft December 5, 2023 22:31
@Joostb Joostb marked this pull request as ready for review December 6, 2023 09:31
@taylorotwell
Copy link
Member

Can you just make isOwnedByCurrentProcess public?

@taylorotwell taylorotwell marked this pull request as draft December 6, 2023 15:02
@Joostb
Copy link
Contributor Author

Joostb commented Dec 6, 2023

Since this doesnt change the contract anymore, would it be ok for you if I change the target to 10.x?

@Joostb Joostb marked this pull request as ready for review December 6, 2023 16:18
@taylorotwell
Copy link
Member

I don't have a big problem with this being sent back to 10.x in this case. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants