laravel/framework · warning · BadMethodCallException
This cache store does not support flushing locks.
Error message
This cache store does not support flushing locks.
What it means
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.
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().
Example fix
// before
Cache::memo()->flushLocks();
// underlying dynamodb store -> BadMethodCallException
// after
$store = Cache::store(config('cache.memo'));
if ($store->getStore() instanceof \Illuminate\Cache\CanFlushLocks) {
$store->flushLocks();
} else {
// fall back to per-key release or switch driver
$store->getStore()->forget('lock:job-' . $id);
} Defensive patterns
Strategy: type-guard
Validate before calling
// Validate the memoized store's underlying store supports flushing locks
$store = Cache::memo()->getStore();
if (! $store->getRepository()->getStore() instanceof \Illuminate\Cache\CanFlushLocks) {
throw new \RuntimeException('Underlying memo store does not support flushing locks.');
}
$store->flushLocks(); Type guard
function memoStoreSupportsFlushLocks(\Illuminate\Cache\Repository $repo): bool
{
return $repo->getStore() instanceof \Illuminate\Cache\CanFlushLocks;
} Try / catch
try {
Cache::memo()->flushLocks();
} catch (\BadMethodCallException $e) {
if (str_contains($e->getMessage(), 'does not support flushing locks')) {
// fall back to per-key release
foreach ($lockKeys as $key) Cache::forget($key);
} else {
throw $e;
}
} Prevention
- 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.
When it happens
Trigger: Calling Cache::memo()->flushLocks() when the memoized repository's underlying store is dynamodb, memcached, or null — none of which implement CanFlushLocks.
Common situations: Test/admin cleanup using Cache::memo()->flushLocks() with CACHE_DRIVER=dynamodb. Production using memcached as the memoized store and attempting periodic lock flush.
Related errors
- This cache store does not support locks.
- Flushing locks is only supported when the lock store is…
- Flushing locks is only supported when the lock store is…
- Flushing locks is only supported when the lock store is…
- Flushing locks is only supported when the lock store is…
AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11).
Data as JSON: /api/errors/ad60aa80f2cc9530.
Report an issue: GitHub.
Appendix: source
Thrown at src/Illuminate/Cache/MemoizedStore.php:210
{
if (! $this->repository->getStore() instanceof LockProvider) {
throw new BadMethodCallException('This cache store does not support locks.');
}
return $this->repository->getStore()->restoreLock(...func_get_args());
}
/**
* Flush all locks managed by the store.
*
* @throws \BadMethodCallException
*/
public function flushLocks(): bool
{
$store = $this->repository->getStore();
if (! $store instanceof CanFlushLocks) {
throw new BadMethodCallException('This cache store does not support flushing locks.');
}
return $store->flushLocks();
}
/**
* Determine if the lock store is separate from the cache store.
*/
public function hasSeparateLockStore(): bool
{
$store = $this->repository->getStore();
return $store instanceof CanFlushLocks && $store->hasSeparateLockStore();
}
/**
* Adjust the expiration time of a cached item.
*View on GitHub (pinned to e0f6eb3518)