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

  1. Guard the call: if ($cache->supportsFlushingLocks()) { $cache->flushLocks(); }
  2. Point the command at a lock-capable store (redis/memcached/database).
  3. 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

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


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)