laravel/framework · error · BadMethodCallException
This cache store does not support flushing locks.
Error message
This cache store does not support flushing locks.
What it means
Thrown by Repository::flushLocks() when supportsFlushingLocks() is false. This requires both a LockProvider store AND a flushLocks() implementation; some stores support locking but cannot flush locks globally, so this is stricter than the funnel() check.
Solutions
- Guard the call: if ($cache->supportsFlushingLocks()) { $cache->flushLocks(); }
- Point the command at a lock-capable store (redis/memcached/database).
- In tests, skip or stub flushLocks() for non-lock stores.
Example fix
// before
Cache::flushLocks(); // throws on array store
// after
if (Cache::supportsFlushingLocks()) {
Cache::flushLocks();
} Defensive patterns
Strategy: type-guard
Validate before calling
if (Cache::supportsFlushingLocks()) {
Cache::flushLocks();
} Type guard
// Repository exposes supportsFlushingLocks() directly; prefer it.
function canFlushLocks(\Illuminate\Cache\Repository $cache): bool {
return $cache->supportsFlushingLocks();
} Try / catch
try {
Cache::flushLocks();
} catch (\BadMethodCallException $e) {
// store cannot flush locks; ignore in non-lock environments
} Prevention
- Always call supportsFlushingLocks() before flushLocks().
- Restrict lock-flush maintenance commands to environments with a lock-capable store.
- In tests, stub or skip flushLocks() for non-lock stores.
When it happens
Trigger: Calling Cache::flushLocks() on a store that is not a LockProvider, or is a LockProvider but does not expose flushLocks() (e.g. array store, some custom drivers).
Common situations: Calling flushLocks() in a maintenance command or test teardown against the array/file store; running lock-cleanup jobs in CI with the default test store.
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/11705eab96172335.
Report an issue: GitHub.
Appendix: source
Thrown at src/Illuminate/Cache/Repository.php:823
$this->event(new CacheFlushed($this->getName()));
} else {
$this->event(new CacheFlushFailed($this->getName()));
}
return $result;
}
/**
* Flush all locks from the cache store.
*
* @throws \BadMethodCallException
*/
public function flushLocks(): bool
{
$store = $this->getStore();
if (! $this->supportsFlushingLocks()) {
throw new BadMethodCallException('This cache store does not support flushing locks.');
}
$this->event(new CacheLocksFlushing($this->getName()));
$result = $store->flushLocks();
if ($result) {
$this->event(new CacheLocksFlushed($this->getName()));
} else {
$this->event(new CacheLocksFlushFailed($this->getName()));
}
return $result;
}
/**
* Begin executing a new tags operation if the store supports it.
*View on GitHub (pinned to e0f6eb3518)