{"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/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Cache/ArrayStore.php#L220-L256","documentation":"ArrayStore::flushLocks() throws if hasSeparateLockStore() is false. The ArrayStore is an in-memory store typically used in tests; its hasSeparateLockStore() normally returns true, so this guard exists for the contract case where the store is wrapped/configured to share a single backing store with locks. Flushing only locks is unsafe when they live in the same storage as cache values.","triggerScenarios":"Calling Cache::store('array')->getStore()->flushLocks() on an ArrayStore whose hasSeparateLockStore() was overridden to false (e.g. a subclass), or invoking flushLocks() through a path that does not honor the separation. In vanilla ArrayStore this is effectively unreachable because hasSeparateLockStore() returns true.","commonSituations":"Subclassing ArrayStore for tests and overriding hasSeparateLockStore(). Misconfiguring a custom in-memory store. Indirectly hitting the shared CanFlushLocks contract via a wrapper.","solutions":["If you need lock-only flushing on ArrayStore, ensure hasSeparateLockStore() returns true (the default) so the lock array is flushed independently.","If using a subclass, override hasSeparateLockStore() to return true when locks are stored in a distinct property.","If the store genuinely shares storage, call flush() to clear everything instead of flushLocks()."],"exampleFix":"// before\n$store = new ArrayStore();\n// (subclass forced hasSeparateLockStore() = false)\n$store->flushLocks(); // throws\n\n// after\n$store->flush(); // clears both values and locks\n// or ensure hasSeparateLockStore() returns true in your subclass","handlingStrategy":"validation","validationCode":"$store = Cache::store('array')->getStore();\nif (method_exists($store, 'hasSeparateLockStore') && ! $store->hasSeparateLockStore()) {\n    // do not call flushLocks(); use flush() instead\n    Cache::store('array')->flush();\n} else {\n    $store->flushLocks();\n}","typeGuard":"function canFlushLocksSeparately(\\Illuminate\\Contracts\\Cache\\Store $store): bool\n{\n    return $store instanceof \\Illuminate\\Contracts\\Cache\\CanFlushLocks\n        && (! method_exists($store, 'hasSeparateLockStore') || $store->hasSeparateLockStore());\n}","tryCatchPattern":"try {\n    Cache::store('array')->getStore()->flushLocks();\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'lock store is separate')) {\n        Cache::store('array')->flush();\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Check hasSeparateLockStore() before flushLocks().","In tests use flush() to clear state.","Avoid subclassing ArrayStore with a non-separating lock store."],"tags":["cache","array-store","locks","configuration"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}