Symfony主义APCu缓存未清除,“ apcu_store”返回false

问题描述

我的PHP版本是7.4.3,并且还配置并启用了APCu扩展名。我在Symfony 4应用程序中使用Doctrine APCu缓存。现在,每当我尝试清除resultquerymetadata缓存时,都会出现以下错误。

php bin/console doctrine:cache:clear-result

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

问题仅适用于Symfony App。在核心PHP apcu_store中工作正常。 apcu_store仅在Symfony应用的本地主机上返回false。

下面是我的配置文件

doctrine.yaml

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

相同的代码正在我的产品上运行,但不适用于我的本地。结果无法清除。

解决方法

我不是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来获得结果,但是应该可以...

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

干杯。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...