首页 > 解决方案 > Symfony Doctrine APCu cache not clearing, "apcu_store" returning false

问题描述

My PHP version is 7.4.3 and APCu extension is also configured and enabled. I'm using Doctrine APCu cache in my Symfony 4 application. Now whenever I try to clear the result or query or metadata cache I got following error.

php bin/console doctrine:cache:clear-result

// Clearing all Result cache entries                                                                                                                                                            
[ERROR] No cache entries were deleted.                                                                                 

Issue is only for Symfony App. In core PHP apcu_store is working fine. apcu_store returning false on my localhost for Symfony app only.

Below is my doctrine config file

doctrine.yaml

doctrine:
    orm:
        metadata_cache_driver: apcu
        query_cache_driver: apcu
        result_cache_driver: apcu   
        .....

Same code is working on my production but not on my local. Result not clearing.

标签: phpsymfonydoctrine-ormsymfony4apcu

解决方案


我不是 Symfony 的专家,但也许如果没有缓存条目被删除,Symfony 就没有使用它。 https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/caching.html

<?php
$query = $em->createQuery('select u from \Entities\User u');
$query->useResultCache(true);

您确定要在清除结果之前保存结果吗?从来没有使用 apcu 来获得结果,但它应该可以工作......

也许您可以通过一些示例提供有关您的配置的其他信息。

干杯。


推荐阅读