【问题标题】:Symfony cache clear has no effectSymfony缓存清除没有效果
【发布时间】:2021-07-07 17:44:39
【问题描述】:

我用

$cache = new FilesystemAdapter();
var_dump($cache->getItem('test_cache_key'));
exit;

现在这个值没有记录在任何地方。我已经尝试了所有可能的命令:

php bin/console cache:clear
php bin/console cache:pool:prune
php bin/console cache:pool:clear cache.app

还有其他类似的变化形式。

我也在清除 /tmp。 并删除了 Symfony 项目中的 /var/cache 目录。

但一切都是徒劳的。当 $cache->getItem('test_cache_key') 被调用时,缓存保持在原地。

object(Symfony\Component\Cache\CacheItem)#2566 (9) {
  ["key":protected]=>
  string(14) "test_cache_key"
  ["value":protected]=>
  string(16) "test_cache_value"
  ["isHit":protected]=>
  bool(true)
  ["expiry":protected]=>
  NULL
  ["metadata":protected]=>
  array(0) {
  }
  ["newMetadata":protected]=>
  array(0) {
  }
  ["innerItem":protected]=>
  NULL
  ["poolHash":protected]=>
  NULL
  ["isTaggable":protected]=>
  bool(false)
}

我不知道该怎么做。请帮帮我。

更新。

Current configuration for "framework.cache"
===========================================

prefix_seed: _%kernel.project_dir%.%kernel.container_class%
app: cache.adapter.filesystem
system: cache.adapter.system
directory: '%kernel.cache_dir%/pools'
default_redis_provider: 'redis://localhost'
default_memcached_provider: 'memcached://localhost'
default_pdo_provider: database_connection
pools: {  }

【问题讨论】:

  • 你能显示你的缓存配置吗?最好是php bin/console debug:config framework cache生成的,而不仅仅是yaml配置
  • “framework.cache”的当前配置 ================================== ========= prefix_seed: _%kernel.project_dir%.%kernel.container_class% app: cache.adapter.filesystem 系统: cache.adapter.system 目录: '%kernel.cache_dir%/pools' default_redis_provider: 'redis://localhost' default_memcached_provider: 'memcached://localhost' default_pdo_provider: database_connection pools: { }
  • 在 UPD 后格式化

标签: php symfony caching


【解决方案1】:

删除 /var/cache 目录通常有效(或习惯)但是 经过一番阅读,我看到一些池可以被memcached。如果之后它仍然存在,这一定是你的情况。

至少有三种不同的缓存清除器:cache.global_clearercache.system_clearercache.app_clearer。您已经使用cache:clear 命令调用了cache.system_clearer,但显然这并没有得到一切。你需要调用cache.global_clearer:

清除所有地方的所有缓存:

> php bin/console cache:pool:clear cache.global_clearer

--https://symfony.com/doc/current/cache.html#clearing-the-cache

【讨论】:

  • 不行(而且我没有安装memcached和redis
猜你喜欢
  • 1970-01-01
  • 2021-11-17
  • 2018-12-12
  • 2017-12-21
  • 2013-03-26
  • 2015-07-21
  • 1970-01-01
  • 2016-05-09
  • 1970-01-01
相关资源
最近更新 更多