{"record":{"id":"ad60aa80f2cc9530","repo":"laravel/framework","slug":"this-cache-store-does-not-support-flushing-locks","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":"warning","filePath":"src/Illuminate/Cache/MemoizedStore.php","lineNumber":210,"sourceCode":"    {\n        if (! $this->repository->getStore() instanceof LockProvider) {\n            throw new BadMethodCallException('This cache store does not support locks.');\n        }\n\n        return $this->repository->getStore()->restoreLock(...func_get_args());\n    }\n\n    /**\n     * Flush all locks managed by the store.\n     *\n     * @throws \\BadMethodCallException\n     */\n    public function flushLocks(): bool\n    {\n        $store = $this->repository->getStore();\n\n        if (! $store instanceof CanFlushLocks) {\n            throw new BadMethodCallException('This cache store does not support flushing locks.');\n        }\n\n        return $store->flushLocks();\n    }\n\n    /**\n     * Determine if the lock store is separate from the cache store.\n     */\n    public function hasSeparateLockStore(): bool\n    {\n        $store = $this->repository->getStore();\n\n        return $store instanceof CanFlushLocks && $store->hasSeparateLockStore();\n    }\n\n    /**\n     * Adjust the expiration time of a cached item.\n     *","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Cache/MemoizedStore.php#L192-L228","documentation":"MemoizedStore::flushLocks requires the underlying store to implement Illuminate\\Cache\\CanFlushLocks (RedisStore, DatabaseStore, FileStore, ArrayStore all do). If the wrapped store does not (e.g., DynamoDbStore, MemcachedStore, NullStore), flushing locks through the memo layer is refused with BadMethodCallException. This is distinct from the 'separate lock store' RuntimeException raised by stores that do implement CanFlushLocks.","triggerScenarios":"Calling Cache::memo()->flushLocks() when the memoized repository's underlying store is dynamodb, memcached, or null — none of which implement CanFlushLocks.","commonSituations":"Test/admin cleanup using Cache::memo()->flushLocks() with CACHE_DRIVER=dynamodb. Production using memcached as the memoized store and attempting periodic lock flush.","solutions":["Call flushLocks() on the non-memoized store only if it implements CanFlushLocks: Cache::store('redis')->flushLocks().","Switch the memoized underlying store to one implementing CanFlushLocks (redis, database, file, array) when lock-flush support is required.","Guard the call: Cache::memo()->getStore() instanceof \\Illuminate\\Cache\\CanFlushLocks before invoking flushLocks()."],"exampleFix":"// before\nCache::memo()->flushLocks();\n// underlying dynamodb store -> BadMethodCallException\n\n// after\n$store = Cache::store(config('cache.memo'));\nif ($store->getStore() instanceof \\Illuminate\\Cache\\CanFlushLocks) {\n    $store->flushLocks();\n} else {\n    // fall back to per-key release or switch driver\n    $store->getStore()->forget('lock:job-' . $id);\n}","handlingStrategy":"type-guard","validationCode":"// Validate the memoized store's underlying store supports flushing locks\n$store = Cache::memo()->getStore();\nif (! $store->getRepository()->getStore() instanceof \\Illuminate\\Cache\\CanFlushLocks) {\n    throw new \\RuntimeException('Underlying memo store does not support flushing locks.');\n}\n$store->flushLocks();","typeGuard":"function memoStoreSupportsFlushLocks(\\Illuminate\\Cache\\Repository $repo): bool\n{\n    return $repo->getStore() instanceof \\Illuminate\\Cache\\CanFlushLocks;\n}","tryCatchPattern":"try {\n    Cache::memo()->flushLocks();\n} catch (\\BadMethodCallException $e) {\n    if (str_contains($e->getMessage(), 'does not support flushing locks')) {\n        // fall back to per-key release\n        foreach ($lockKeys as $key) Cache::forget($key);\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Use a driver implementing CanFlushLocks (redis, database, file, array) when memo flushLocks is needed.","Add a project helper flushLocksSafe() that branches on CanFlushLocks.","Document which drivers support flushLocks in the team cache guide."],"tags":["cache","memoized","locks","bad-method-call"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}