[laravel] This cache store does not support tagging 해결방법

태그가 지정된 캐시를 저장하고자 할때 ‘This cache store does not support tagging.’ 라는 에러가 발생했다.

코드 :

$articles = Cache::tags('article')->remember.env($cacheKey, now()->addMinutes(30), function () {
            return Article::latest()->paginate(10);
        });

문제해결:

캐시드라이버가 file 또는 database 에서는 태그기능을 지원하지 않는다.
.env 에서 CACHE_DRIVER값을 redis 또는 memcache또는 array로 변경한다.

#CACHE_DRIVER=file
CACHE_DRIVER=array

설정캐시를 날려 수정한 사항이 반영되도록 한다.

php artisan config:cache

만약 드라이버를 수정하지 않고 특정 위치에서만 사용하고 싶을때는 Cache파사드의 store메서드에 드라이버를 인자로 전달하면 된다.

        $articles = Cache::store('array')->tags('article')->remember($cacheKey, now()->addMinutes(30), function () {
            return Article::latest()->paginate(10);
        });