{"id":"11705eab96172335","repo":"laravel/framework","slug":"this-cache-store-does-not-support-flushing-locks-11705e","errorCode":null,"errorMessage":"This cache store does not support flushing locks.","messagePattern":"This cache store does not support flushing locks\\.","errorType":"exception","errorClass":"BadMethodCallException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Cache/Repository.php","lineNumber":823,"sourceCode":"            $this->event(new CacheFlushed($this->getName()));\n        } else {\n            $this->event(new CacheFlushFailed($this->getName()));\n        }\n\n        return $result;\n    }\n\n    /**\n     * Flush all locks from the cache store.\n     *\n     * @throws \\BadMethodCallException\n     */\n    public function flushLocks(): bool\n    {\n        $store = $this->getStore();\n\n        if (! $this->supportsFlushingLocks()) {\n            throw new BadMethodCallException('This cache store does not support flushing locks.');\n        }\n\n        $this->event(new CacheLocksFlushing($this->getName()));\n\n        $result = $store->flushLocks();\n\n        if ($result) {\n            $this->event(new CacheLocksFlushed($this->getName()));\n        } else {\n            $this->event(new CacheLocksFlushFailed($this->getName()));\n        }\n\n        return $result;\n    }\n\n    /**\n     * Begin executing a new tags operation if the store supports it.\n     *","sourceCodeStart":805,"sourceCodeEnd":841,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Cache/Repository.php#L805-L841","documentation":"Thrown by Cache\\Repository::flushLocks() when the store does not implement Illuminate\\Cache\\CanFlushLocks. Even lock-capable stores (redis/database/memcached) only flush locks if they specifically opt in via that interface.","triggerScenarios":"Calling Cache::flushLocks() (e.g., in a test teardown or maintenance command) on a store that lacks CanFlushLocks, including array/file stores and some custom adapters.","commonSituations":"Test cleanup that calls Cache::flushLocks() while CACHE_STORE=array; a custom Store subclass that implements LockProvider but forgot flushLocks(); a maintenance command run in an env whose driver does not support lock flushing.","solutions":["Guard with the provided capability check: if (Cache::supportsFlushingLocks()) { Cache::flushLocks(); }.","Switch to a store that implements CanFlushLocks (redis/database) for the environment that needs it.","If you wrote a custom Store, implement CanFlushLocks::flushLocks() and clear the lock namespace.","In tests, reset by calling Cache::flush() or by using a fresh array store per test instead of flushLocks()."],"exampleFix":"// before\nCache::flushLocks();\n\n// after\nif (Cache::supportsFlushingLocks()) {\n    Cache::flushLocks();\n}","handlingStrategy":"validation","validationCode":"if (! Cache::supportsFlushingLocks()) {\n    // skip flushLocks() or use Cache::flush()\n}","typeGuard":"function canFlushLocks(): bool {\n    return Cache::supportsFlushingLocks();\n}","tryCatchPattern":"try {\n    Cache::flushLocks();\n} catch (\\BadMethodCallException $e) {\n    // store can't flush locks; fall back to flush() or no-op\n}","preventionTips":["Always gate Cache::flushLocks() with Cache::supportsFlushingLocks().","In tests, use a fresh array store per test instead of flushing locks.","When writing a custom Store, implement CanFlushLocks if you expose locks."],"tags":["cache","locks","config","laravel"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}