mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Need round DateTime from query params for correct build cache key #5495
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 @peter-gribanov on GitHub (Apr 7, 2017).
Originally assigned to: @Ocramius on GitHub.
This query is not be cached because the cache key builder use seconds from query parameter:
Of course, the use of the current time in the query does not allow it to be cached, and therefore it is necessary to use conditionally the current time.
Need round DateTime from params
You can say that this is not your task, but this is the task of the persistence layer, not the layer of business logic.
It looks very strange:
Now i am forced to use this approach, but i do not like it at all.
@peter-gribanov commented on GitHub (Apr 7, 2017):
I could create a simple the Conditionally Current Time object for this:
But it's doesn't work if i use the pattern Specification, because the parameters can be determined at different levels of the specification aggregator.
@Ocramius commented on GitHub (Apr 7, 2017):
This is 100% not the problem of the ORM.
We just take parameters and make a cache key from them, a d cannot round nor apply any assumptions on what the parameters mean.
Please use a fixed value such as
midnight todayor similar instead.Closing as
invalid@holtkamp commented on GitHub (Apr 7, 2017):
@peter-gribanov what about using a 'constant' like a DQL function, I guess
CURRENT_TIMESTAMP()does the trick 😉@Ocramius commented on GitHub (Apr 7, 2017):
@holtkamp that is still broken: now your query isn't idempotent anymore, and therefore not cacheable by definition. Even the rdbms won't cache such a query at low level...
@holtkamp commented on GitHub (Apr 7, 2017):
@Ocramius aah, sorry, yeah, this involves result cache. I had the query cache in mind... Nevermind then!