Browse Source

Removed possible collision in composite cache key #20

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@144 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
master
aterekhov 14 years ago
parent
commit
62fc5a0a49
  1. 20
      cache/CacheKey.php

20
cache/CacheKey.php

@ -11,11 +11,11 @@
class CacheKey
{
protected $key;
protected $params = '';
protected $expire = 0;
/**
* @param string $key
* @param mixed $params
@ -30,20 +30,20 @@ class CacheKey
}
$this->cache = $cacheable->getCache();
$this->expire = $cacheable->getKeyExpire($this->key);
$this->params = (is_array($params)) ? implode('', $params) : $params;
$this->params = (is_array($params)) ? implode('|', $params) : $params;
}
protected function getCacheKey()
{
$params = ($this->params) ? ('_' . $this->params) : '';
return $this->key . $params;
}
protected function getExpire()
{
return $this->expire;
}
/**
* @param int $expire
*/
@ -51,12 +51,12 @@ class CacheKey
{
$this->expire = $expire;
}
public function get()
{
return $this->cache->get($this->getCacheKey());
return $this->cache->get($this->getCacheKey());
}
/**
* @param mixed $value
*/
@ -64,7 +64,7 @@ class CacheKey
{
return $this->cache->set($this->getCacheKey(), $value, $this->expire);
}
public function del()
{
return $this->cache->del($this->getCacheKey());

Loading…
Cancel
Save