Commit 99629012 authored by Antonio Vilar's avatar Antonio Vilar Committed by Marco Pivetta

Used connection params in cache key generation

parent 1b3c36b4
...@@ -88,17 +88,22 @@ class QueryCacheProfile ...@@ -88,17 +88,22 @@ class QueryCacheProfile
} }
/** /**
* Generates the real cache key from query, params and types. * Generates the real cache key from query, params, types and connection parameters.
* *
* @param string $query * @param string $query
* @param array $params * @param array $params
* @param array $types * @param array $types
* @param array $connectionParams
* *
* @return array * @return array
*/ */
public function generateCacheKeys($query, $params, $types) public function generateCacheKeys($query, $params, $types, $connectionParams = array())
{ {
$realCacheKey = $query . "-" . serialize($params) . "-" . serialize($types); $realCacheKey = 'query=' . $query .
'&params=' . serialize($params) .
'&types=' . serialize($types) .
(!empty($connectionParams) ? serialize($connectionParams) : '');
// should the key be automatically generated using the inputs or is the cache key set? // should the key be automatically generated using the inputs or is the cache key set?
if ($this->cacheKey === null) { if ($this->cacheKey === null) {
$cacheKey = sha1($realCacheKey); $cacheKey = sha1($realCacheKey);
......
...@@ -879,7 +879,7 @@ class Connection implements DriverConnection ...@@ -879,7 +879,7 @@ class Connection implements DriverConnection
throw CacheException::noResultDriverConfigured(); throw CacheException::noResultDriverConfigured();
} }
list($cacheKey, $realKey) = $qcp->generateCacheKeys($query, $params, $types); list($cacheKey, $realKey) = $qcp->generateCacheKeys($query, $params, $types, $this->getParams());
// fetch the row pointers entry // fetch the row pointers entry
if ($data = $resultCache->fetch($cacheKey)) { if ($data = $resultCache->fetch($cacheKey)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment