mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
PhpFileCache with Query #6495
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vv12131415 on GitHub (Jun 26, 2020).
Support Question
As it says at the documentation, https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/caching.html#phpfilecache it is perfect fit to set
PhpFileCacheas a cache driver for metadata and query.For metadata it works perfectly, but for query cache (not the result) I see weird behaviour, it just writes to cache and doesn't read from it. That's because
lifetimethat is passed toPhpFileCache::saveis ALWAYSnull.I've debugged the save method and found where the cache lifetime is set.
And I looked at this property
_queryCacheTTL.4fae126459/lib/Doctrine/ORM/Query.php (L192)(which is actually null, not int). Null for cache lifetime means that we cache the result, but when we check it again, it is empty, so we are always writing to cache.Am I doing/configuring something wrong?
Is
_queryCacheTTLset tonullon purpose?@Philosoft commented on GitHub (Jan 29, 2021):
If your previous research was right, than there is no way to fix it from configuration perspective, since
_queryCacheTTLis changing only in 1 place4fae126459/lib/Doctrine/ORM/Query.php (L507-L523)which is never ever called. But is used in
1 test
5801474ba3/tests/Doctrine/Tests/ORM/Query/QueryTest.php (L95-L99)and 1 documentation line
3ef5a30102/docs/en/reference/dql-doctrine-query-language.rst (query-cache-dql-query-only)so as far as I understand the only option to fix it is to modify every query with
->setQueryCacheLifetime(0)@JindrichPilar commented on GitHub (Mar 4, 2021):
I encountered this problem too on 2.7.5 and came to the same conclusion as @vladyslavstartsev.
nullas TTL means expire never in RedisCache, but expire immediatelly in PhpFileCache.In my opininion this is bug in
doctrine/orm, because it passesnullto a method argument that accepts onlyintegerSetting default value of
$_queryCacheTTLto0should fix this. In fact it already has phpdoc@var int, yet it contains null.From quick look at 2.8.x it seem the problem is there too, although property is no longer prefixed with underscore.