【问题标题】:Laravel: This cache store does not support tagging with array or redisLaravel:此缓存存储不支持使用数组或 redis 进行标记
【发布时间】:2020-02-27 08:46:48
【问题描述】:

我的 Laravel 应用程序出现以下错误:

BadMethodCallException
This cache store does not support tagging.

但是,在我的 .env 中,我设置了 CACHE_DRIVER=arrayredis

由于这个问题,我无法使用spatie/laravel-responsecache

重新安装我的应用程序没有帮助。

也许一个包干扰了我的应用程序,但问题是新的。这是我的composer.json

"require": {
    "php": "^7.3",
    "ext-json": "*",
    "doctrine/dbal": "^2.9",
    "felixinx/gtfs-realtime-protobuf-php": "@dev",
    "fideloper/proxy": "^4.0",
    "guzzlehttp/guzzle": "^6.3",
    "laravel/framework": "^6.0",
    "laravel/horizon": "^3.2",
    "laravel/tinker": "^1.0",
    "league/csv": "^9.1",
    "mad-web/laravel-initializer": "^2.0",
    "predis/predis": "^1.1",
    "pusher/pusher-php-server": "~4.0",
    "spatie/laravel-responsecache": "^6.3",
    "symfony/psr-http-message-bridge": "^1.1"
},
"require-dev": {
    "barryvdh/laravel-debugbar": "^3.2",
    "fzaninotto/faker": "^1.4",
    "mockery/mockery": "^1.0",
    "nunomaduro/collision": "^3.0",
    "phpunit/phpunit": "^8.0"
},

【问题讨论】:

  • 根据自述文件,环境变量应该是RESPONSE_CACHE_DRIVER,还要确保清除配置缓存。
  • @Razor 这是一个很好的答案!奇怪的是我之前不用这个变量……
  • 是的,这很奇怪,您可能使用的是旧版本

标签: laravel caching composer-php


【解决方案1】:

使用 php artisan optimize:clear 命令对我有用。它会清除所有内容,我猜清除配置缓存就足够了。

【讨论】:

    【解决方案2】:

    你需要定义RESPONSE_CACHE_DRIVER环境变量:

    RESPONSE_CACHE_DRIVER=array|redis|memcached
    

    【讨论】:

      【解决方案3】:

      在您的 config/responsecache.php 文件中检查 cache_tag

           /*
           * If the cache driver you configured supports tags, you may specify a tag name
           * here. All responses will be tagged. When clearing the responsecache only
           * items with that tag will be flushed.
           *
           * You may use a string or an array here.
           */
          'cache_tag' => '',  // <-- make sure this is empty
      

      如果它已经为空,请尝试将其设置为falsenull。希望对您有所帮助!

      【讨论】:

      • 它是空的,但目标是使用缓存标签!
      猜你喜欢
      • 2021-07-28
      • 1970-01-01
      • 1970-01-01
      • 2021-06-14
      • 2020-04-22
      • 2018-07-24
      • 2023-03-10
      • 2015-09-14
      • 2013-03-22
      相关资源
      最近更新 更多