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 15 years ago
parent
commit
62fc5a0a49
  1. 20
      cache/CacheKey.php

20
cache/CacheKey.php

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

Loading…
Cancel
Save