[DDC-2043] Extra cache operation in DBAL\Cache\ResultCacheStatement.php Created: 26/Sep/12  Updated: 26/Sep/12

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Bogdan Albei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

CentOS, PHP 5.3.10


This is the closeCursor() method in DBAL\Cache\ResultCacheStatement.php:

public function closeCursor()
        if ($this->emptied && $this->data !== null) {
            $data = $this->resultCache->fetch($this->cacheKey);
            if ( ! $data) {
                $data = array();
            $data[$this->realKey] = $this->data;

            $this->resultCache->save($this->cacheKey, $data, $this->lifetime);

We are using Memcache and I noticed an extra GET operation on all cache misses. In the code above I believe the fetch call is not necessary and that the code would do the same without it.
Also, may I ask why is the SQL used as a key in the cached data?

Comment by Christophe Coevoet [ 26/Sep/12 ]

The SQL is used as a key because it is what identifies the query which is done (well, the statement and the parameters)

Comment by Bogdan Albei [ 26/Sep/12 ]

The cacheKey already identifies the query(or at least it should). Would we have cases where different queries would want to use the same cache key?

Generated at Wed Nov 25 19:24:16 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.