{"record":{"id":"118e4bf613b35b28","repo":"laravel/framework","slug":"flushing-locks-is-only-supported-when-the-lock-sto","errorCode":null,"errorMessage":"Flushing locks is only supported when the lock store is separate from the cache store.","messagePattern":"Flushing locks is only supported when the lock store is separate from the cache store\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"src/Illuminate/Cache/ArrayStore.php","lineNumber":238,"sourceCode":"     */\n    public function flush()\n    {\n        $this->storage = [];\n\n        return true;\n    }\n\n    /**\n     * Remove all locks from the store.\n     *\n     * @return bool\n     *\n     * @throws \\RuntimeException\n     */\n    public function flushLocks(): bool\n    {\n        if (! $this->hasSeparateLockStore()) {\n            throw new RuntimeException('Flushing locks is only supported when the lock store is separate from the cache store.');\n        }\n\n        $this->locks = [];\n\n        return true;\n    }\n\n    /**\n     * Get the cache key prefix.\n     *\n     * @return string\n     */\n    public function getPrefix()\n    {\n        return '';\n    }\n\n    /**","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Cache/ArrayStore.php#L220-L256","documentation":"ArrayStore::flushLocks removes all in-memory locks but only when a separate lock store is configured. When locks share the same ArrayStore as the cache (the default), flushing locks would also wipe cache entries, so the operation is refused. hasSeparateLockStore() returns false unless a distinct lock store was injected at construction.","triggerScenarios":"Calling Cache::store('array')->flushLocks() or Cache::flushLocks() against an ArrayStore that was constructed without a separate lock store. Common in tests using CACHE_DRIVER=array and asserting lock cleanup behavior.","commonSituations":"Test suite asserts Cache::flushLocks() to reset state between tests with array driver. Production code defensively flushes locks but the array driver is used for caching with locks co-located.","solutions":["Construct the ArrayStore with a separate lock store: new ArrayStore($lockStore = new ArrayStore()) so hasSeparateLockStore() returns true.","Use Cache::forget() or release individual locks via $lock->release() instead of flushLocks() when using the array driver.","Switch to a driver with native lock separation (redis, database) for the production path that needs flushLocks()."],"exampleFix":"// before\n$store = new ArrayStore();\n$store->flushLocks(); // RuntimeException\n\n// after\n$cacheStore = new ArrayStore();\n$lockStore = new ArrayStore();\n$store = new ArrayStore(lockStore: $lockStore);\n// hasSeparateLockStore() now true\n$store->flushLocks();","handlingStrategy":"validation","validationCode":"// Validate the array store has a separate lock store before flushing\n$store = Cache::store('array')->getStore();\nif (! $store->hasSeparateLockStore()) {\n    // skip or release locks individually\n    return;\n}\n$store->flushLocks();","typeGuard":"function storeSupportsFlushLocks(\\Illuminate\\Contracts\\Cache\\Store $store): bool\n{\n    return $store instanceof \\Illuminate\\Cache\\CanFlushLocks\n        && (! method_exists($store, 'hasSeparateLockStore') || $store->hasSeparateLockStore());\n}","tryCatchPattern":null,"preventionTips":["When using the array driver in tests that exercise locks, construct it with a separate lock store.","Document that flushLocks() requires a separate lock store at construction time.","Default to release() per lock rather than flushLocks() for cleanup in test teardown."],"tags":["cache","locks","array-store","configuration"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}