False-negative cache hit due to low accuracy (up to a second) of comparing the expiration date with the current date
I found frequent cache misses when using the Psr6ToYiiCache
adapter.
As a result of debugging, it became clear that it was a matter of comparing dates to the nearest second.
The Yii2
cache does not return the expiration date, only the value itself, so the expiration date is equal to the current date (as specified in the Psr6ToYii2CacheItem
constructor, where ttl
is most often not passed).
Which, when compared in isHit
with an accuracy of up to a second, often led to a false cache miss - although the result was in the cache.
I'm going to create a PR to fix this.