You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue I am encountering is that the DefaultQueryCache implementation does not behave as expected with Cache::MODE_REFRESH.
According to the code comments and documentation:
/** * The query will never read items from the cache, * but will refresh items to the cache as it reads them from the database. */publicconstMODE_REFRESH = 4;
As a side note, it would be nice if the cacheMode was more easily configurable. A potential way to do this would be to have the QueryCache interface defined a method, e.g. getQueryCacheKey, which would create the QueryCacheKey instance, offering an opportunity for customization of the QueryCacheKey::cacheMode attribute.
Right now, in my decorator, I basically create a new QueryCacheKey instead, and pass that along to the DefaultQueryCache implementation to achieve this, and, as far as I can tell, this is the only method available to customize the cacheMode, even though it seems to be a public API and is present in the documentation.
I'd be willing to submit a PR for this, if it is agreed upon.
The text was updated successfully, but these errors were encountered:
Bug Report
Summary
I'm using a decorator on top of the
DefaultQueryCache
implementation so that I can control thecacheMode
used by Doctrine, as it defaults toCache::MODE_NORMAL
without possibility of change.The issue I am encountering is that the
DefaultQueryCache
implementation does not behave as expected withCache::MODE_REFRESH
.According to the code comments and documentation:
https://www.doctrine-project.org/projects/doctrine-orm/en/3.3/reference/second-level-cache.html#cache-mode
Current behavior
The
DefaultQueryCache
implementation does not refresh items into the cache whencacheMode
isREFRESH
.Expected behavior
The
DefaultQueryCache
verifies if an item exists in the cache and, if it does, andcacheMode
isREFRESH
, it refreshes the value in the cache.How to reproduce
Invoke the
DefaultQueryCache::put
method with aQueryCacheKey
that has thecacheMode
attribute set toCache::MODE_REFRESH
.The
put
implementation exists early, on the following check: https://github.com/doctrine/orm/blob/3.3.x/src/Cache/DefaultQueryCache.php#L218-L220No data is refreshed into the cache.
Side Note
As a side note, it would be nice if the
cacheMode
was more easily configurable. A potential way to do this would be to have theQueryCache
interface defined a method, e.g.getQueryCacheKey
, which would create theQueryCacheKey
instance, offering an opportunity for customization of theQueryCacheKey::cacheMode
attribute.Right now, in my decorator, I basically create a new
QueryCacheKey
instead, and pass that along to theDefaultQueryCache
implementation to achieve this, and, as far as I can tell, this is the only method available to customize thecacheMode
, even though it seems to be a public API and is present in the documentation.I'd be willing to submit a PR for this, if it is agreed upon.
The text was updated successfully, but these errors were encountered: