[13.x] Implement CanFlushLocks on FailoverStore#59738
Open
sumaiazaman wants to merge 2 commits intolaravel:13.xfrom
Open
[13.x] Implement CanFlushLocks on FailoverStore#59738sumaiazaman wants to merge 2 commits intolaravel:13.xfrom
sumaiazaman wants to merge 2 commits intolaravel:13.xfrom
Conversation
Co-Authored-By: Sumaiya Zaman <saktar50.cse@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
FailoverStorenow implementsCanFlushLocksand theflushLocks()/hasSeparateLockStore()methodsCache::flushLocks()now works when thefailovercache driver is in useContext
Every cache store that ships with Laravel implements
CanFlushLocks:CanFlushLocksbeforeCanFlushLocksafterArrayStoreDatabaseStoreFileStoreRedisStoreFailoverStoreFailoverStorealready implementsLockProvider(for acquiring locks), but callingCache::flushLocks()with the failover driver threw"This cache store does not support flushing locks."because the store didn't implementCanFlushLocks.Solution
Added
CanFlushLocksto the class declaration and implemented two methods:flushLocks(): bool— iterates through every backing store and callsflushLocks()on those that implementCanFlushLocks. UnlikeattemptOnAllStores()(which returns on the first success), this flushes all stores, because locks may have been acquired on any of them during failover.hasSeparateLockStore(): bool— returnstrue. The failover store delegates entirely to its backing stores, each of which manages lock storage independently.Example
Before:
After:
Why no breaking changes
This is a purely additive change. No existing method signatures are modified, and no existing callers are affected.
Changes
src/Illuminate/Cache/FailoverStore.php— addedCanFlushLocksimport, added to class declaration, implementedflushLocks()andhasSeparateLockStore()tests/Cache/CacheFailoverStoreTest.php— new unit test fileTest Plan
php83 vendor/bin/phpunit tests/Cache/CacheFailoverStoreTest.php— all 3 tests pass