Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDC-2043: Extra cache operation in DBAL\Cache\ResultCacheStatement.php #4178

Closed
doctrinebot opened this issue Sep 26, 2012 · 3 comments · Fixed by #5003
Closed

DDC-2043: Extra cache operation in DBAL\Cache\ResultCacheStatement.php #4178

doctrinebot opened this issue Sep 26, 2012 · 3 comments · Fixed by #5003
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user bogdan.albei:

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

public function closeCursor()
    {
        $this->statement->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);
            unset($this->data);
        }
    }

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?

@doctrinebot
Copy link
Author

Comment created by stof:

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

@doctrinebot
Copy link
Author

Comment created by bogdan.albei:

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?

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants