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
However, this only works in context of AbstractQuery and QueryBuilder, it is not directly modifiable for queries such as $this->repository->findBy(<>), which use a hardcoded cache mode value of CacheMode::NORMAL.
My use case: I am remotely controlling the cache mode for my application, and would like L2 cache to be responsive of this too, not just queries issue via AbstractQuery or QueryBuilder.
To achieve this, I would like to roll my own 2nd level CacheFactory, which is allowed by the Doctrine Bundle for Symfony via orm.entity_managers.default.second_level_cache.factory, and decorate the EntityPersisters created by the factory.
Then, if the CachedPersister interface would expose a setter and getter for the 'cacheMode', and the AbstractEntityPersister used the getter when constructing the QueryCacheKey instead of hard-coding the cache mode, it would also be possible to control the caching mode for L2 cache.
So, in summary, this would require:
two new interface methods for the CachedPersister, getCacheMode and setCacheMode
changing the AbstractEntityPersister to use getCacheMode instead of hard-coding the value to CacheMode::NORMAL at all times
I can raise a PR with this change, provided a maintainer reviews this idea and approves of it.
Thank you!
The text was updated successfully, but these errors were encountered:
Feature Request
Summary
The query cache mode using in L2 cache is defined in-line, when constructing the QueryCacheKey:
https://github.com/doctrine/orm/blob/3.2.x/src/Cache/Persister/Entity/AbstractEntityPersister.php#L305
https://github.com/doctrine/orm/blob/3.2.x/src/Cache/Persister/Entity/AbstractEntityPersister.php#L344
https://github.com/doctrine/orm/blob/3.2.x/src/Cache/Persister/Entity/AbstractEntityPersister.php#L436
This is hinted in the documentation and is a useful concept for controlling how the cache is being used, here:
https://www.doctrine-project.org/projects/doctrine-orm/en/3.2/reference/second-level-cache.html#cache-mode
However, this only works in context of AbstractQuery and QueryBuilder, it is not directly modifiable for queries such as
$this->repository->findBy(<>)
, which use a hardcoded cache mode value ofCacheMode::NORMAL
.My use case: I am remotely controlling the cache mode for my application, and would like L2 cache to be responsive of this too, not just queries issue via
AbstractQuery
orQueryBuilder
.To achieve this, I would like to roll my own 2nd level CacheFactory, which is allowed by the Doctrine Bundle for Symfony via
orm.entity_managers.default.second_level_cache.factory
, and decorate theEntityPersisters
created by the factory.Then, if the CachedPersister interface would expose a setter and getter for the 'cacheMode', and the AbstractEntityPersister used the getter when constructing the QueryCacheKey instead of hard-coding the cache mode, it would also be possible to control the caching mode for L2 cache.
So, in summary, this would require:
CachedPersister
,getCacheMode
andsetCacheMode
getCacheMode
instead of hard-coding the value toCacheMode::NORMAL
at all timesI can raise a PR with this change, provided a maintainer reviews this idea and approves of it.
Thank you!
The text was updated successfully, but these errors were encountered: