gpt4 book ai didi

symfony - Doctrine query_cache 自动过期

转载 作者:行者123 更新时间:2023-12-03 06:36:25 25 4
gpt4 key购买 nike

我通过使用 composer bundle sncRedisBundle 来使用 symfony 3.4 + Doction + redis

在我的 config.yml 中,我启用了 学说查询缓存 :

orm:
default_entity_manager: default
entity_managers:
default:
connection: default
auto_mapping: false
metadata_cache_driver: redis
query_cache_driver: redis
result_cache_driver: redis # !!!

snc_redis:
clients:

doctrine:
type: predis
alias: doctrine_redis
dsn: "%redis_dsn_doctrine%"
logging: false
options:
connection_persistent: true

doctrine:
query_cache: #!!!!!!!!
#it caches the translation from Doctrine's DQL into SQL.
client: doctrine_redis
namespace: shop_doctrine_query
entity_manager: [default, legacy]

由教义为其 result_cache 设置的键永不过期:
enter image description here

如何自动调用 \Doctrine\ORM\Query::setQueryCacheLifetime或使该缓存过期。 (注意我无权在此服务器上设置 redis 驱逐策略)。

最佳答案

我认为 Doctrine 查询缓存生存期不是在 doctrine 包中配置,也不是在 redis 包中配置,而是在框架包中配置,您可以在其中设置缓存池。

你应该看看this issue用户询问如何使用 Doctrine Cache 配置 RedisCluster。 B-Galati 用一个配置示例来回答,它定义了学说结果缓存的生命周期。

你能不能试试这样的:

framework:
cache:
pools:
cache.doctrine.orm.default.query: ## I'm not sure of this name
adapter: cache.app
default_lifetime: 25200 # 1 week

或者

framework:
cache:
pools:
doctrine.query_cache_pool:
adapter: cache.app
default_lifetime: 25200 # 1 week
symfony console cache:pool:list命令可以帮助您识别池和 symfony console cache:pool:prune可以帮助您查看过期查询是否已删除。

关于symfony - Doctrine query_cache 自动过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60817724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com