Doctrine result cache and DateTime params

Viewed 20

How to get result cache working with DateTime params up to seconds? Since those params change every second they can't be cached and so result cache becomes useless. I'm not sure what's the technique dealing with it, I was thinking maybe it would be possible to ID the query without taking into account the params?

1 Answers

Okay, apparently resultCacheId is useless:

if ($data = $resultCache->fetch($cacheKey)) {
    // is the real key part of this row pointers map or is the cache only pointing to other cache keys?
    if (isset($data[$realKey])) {
        $stmt = new ArrayStatement($data[$realKey]);
    } elseif (array_key_exists($realKey, $data)) {
        $stmt = new ArrayStatement(array());
    }
}

if (!isset($stmt)) {
    $stmt = new ResultCacheStatement($this->executeQuery($query, $params, $types), $resultCache, $cacheKey, $realKey, $qcp->getLifetime());
}

After getting the data by the resultCacheId, it still checks the result by realKey (which is calculated including the params) and of course won't find it. So we're getting the cache populated, but it's not being used.

Related