{"id":"34a3d607175be015","repo":"laravel/framework","slug":"this-cache-store-does-not-support-tagging","errorCode":null,"errorMessage":"This cache store does not support tagging.","messagePattern":"This cache store does not support tagging\\.","errorType":"exception","errorClass":"BadMethodCallException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Cache/Repository.php","lineNumber":850,"sourceCode":"        } else {\n            $this->event(new CacheLocksFlushFailed($this->getName()));\n        }\n\n        return $result;\n    }\n\n    /**\n     * Begin executing a new tags operation if the store supports it.\n     *\n     * @param  mixed  $names\n     * @return \\Illuminate\\Cache\\TaggedCache\n     *\n     * @throws \\BadMethodCallException\n     */\n    public function tags($names)\n    {\n        if (! $this->supportsTags()) {\n            throw new BadMethodCallException('This cache store does not support tagging.');\n        }\n\n        $cache = $this->store->tags(is_array($names) ? $names : func_get_args());\n\n        $cache->config = $this->config;\n\n        if (! is_null($this->events)) {\n            $cache->setEventDispatcher($this->events);\n        }\n\n        return $cache->setDefaultCacheTime($this->default);\n    }\n\n    /**\n     * Format the key for a cache item.\n     *\n     * @param  string  $key\n     * @return string","sourceCodeStart":832,"sourceCodeEnd":868,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Cache/Repository.php#L832-L868","documentation":"Thrown by Cache\\Repository::tags() when supportsTags() is false, i.e. the store has no tags() method (method_exists check). Tagged caching is only available on stores that implement tag sets, such as redis, memcached, array, and database (with the tag table). File and DynamoDB stores do not.","triggerScenarios":"Calling Cache::tags(['users'])->put(...) or Cache::tags(['users'])->flush() while CACHE_STORE is file, dynamodb, or another store without a tags() method.","commonSituations":"Local dev using CACHE_STORE=file hitting code that tags cached query results; running the app with a custom Store that did not implement tags(); CI using array driver but the test calls tags() on a cache facade backed by something else.","solutions":["Switch CACHE_STORE to redis, memcached, database, or array (array supports tags).","Guard the call: if (Cache::supportsTags()) { Cache::tags(['users'])->flush(); }.","Refactor to manual key-prefix invalidation if you must keep a non-tagging store.","If using the database store, ensure migrations for the cache and cache_tags tables are present."],"exampleFix":"// before\nCache::tags(['posts'])->flush();\n\n// after\nif (Cache::supportsTags()) {\n    Cache::tags(['posts'])->flush();\n}\n// or .env: CACHE_STORE=redis","handlingStrategy":"validation","validationCode":"if (! Cache::supportsTags()) {\n    // use a non-tagged key scheme or switch store\n}","typeGuard":"function cacheSupportsTags(): bool {\n    return Cache::supportsTags();\n}","tryCatchPattern":"try {\n    Cache::tags(['users'])->flush();\n} catch (\\BadMethodCallException $e) {\n    // store can't tag; flush by key prefix instead\n}","preventionTips":["Gate Cache::tags() with Cache::supportsTags().","Align CACHE_STORE across envs (use redis/database/array where tags are needed).","For the database store, ensure the cache_tags migration has run."],"tags":["cache","tags","config","laravel"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}