Skip to content

Commit

Permalink
[mms] Cache prefix should be handled by Hashtable driver, not underly…
Browse files Browse the repository at this point in the history
…ing backend object.
  • Loading branch information
slusarz committed Feb 4, 2014
1 parent 4e2edb8 commit 9eee4ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 8 additions & 11 deletions framework/Cache/lib/Horde/Cache/Storage/Hashtable.php
Expand Up @@ -44,34 +44,31 @@ public function __construct(array $params = array())
throw new InvalidArgumentException('Missing hashtable parameter.');
}

parent::__construct($params);
parent::__construct(array_merge(array(
'prefix' => ''
), $params));
}

/**
*/
protected function _initOb()
{
if (isset($this->_params['prefix'])) {
$this->_hash = clone $this->_params['hashtable'];
$this->_hash->prefix = $this->_params['prefix'];
} else {
$this->_hash = $this->_params['hashtable'];
}
$this->_hash = $this->_params['hashtable'];
}

/**
* NOTE: This driver ignores the lifetime argument.
*/
public function get($key, $lifetime = 0)
{
return $this->_hash->get($key);
return $this->_hash->get($this->_params['prefix'] . $key);
}

/**
*/
public function set($key, $data, $lifetime = 0)
{
$this->_hash->set($key, $data, array_filter(array(
$this->_hash->set($this->_params['prefix'] . $key, $data, array_filter(array(
'timeout' => $lifetime
)));
}
Expand All @@ -81,14 +78,14 @@ public function set($key, $data, $lifetime = 0)
*/
public function exists($key, $lifetime = 0)
{
return $this->_hash->exists($key);
return $this->_hash->exists($this->_params['prefix'] . $key);
}

/**
*/
public function expire($key)
{
$this->_hash->delete($key);
$this->_hash->delete($this->_params['prefix'] . $key);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions framework/Cache/package.xml
Expand Up @@ -27,6 +27,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Cache prefix should be handled by Hashtable driver, not underlying backend object.
* [mms] Fix cloning the HashTable object when a prefix parameter is specified.
</notes>
<contents>
Expand Down Expand Up @@ -546,6 +547,7 @@ Initial packaging.
<date>2014-01-24</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Cache prefix should be handled by Hashtable driver, not underlying backend object.
* [mms] Fix cloning the HashTable object when a prefix parameter is specified.
</notes>
</release>
Expand Down

0 comments on commit 9eee4ba

Please sign in to comment.