Memcache, refactoring, View helpers, #16
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@124 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
48
cache/CacheKeySet.php
vendored
Normal file
48
cache/CacheKeySet.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
* @package Majestic
|
||||
* @subpackage Cache
|
||||
* @since 2010-03-10
|
||||
* @version SVN: $Id$
|
||||
* @filesource $URL$
|
||||
*/
|
||||
|
||||
class CacheKeySet extends CacheKey
|
||||
{
|
||||
public function get()
|
||||
{
|
||||
$set = $this->cache->get($this->key);
|
||||
$item_key = $this->getCacheKey();
|
||||
|
||||
if (!is_array($set) || !array_key_exists($item_key, $set)) {
|
||||
return false;
|
||||
}
|
||||
return $this->cache->get($item_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function set($value)
|
||||
{
|
||||
$set = $this->cache->get($this->key);
|
||||
if (!is_array($set)) {
|
||||
$set = array();
|
||||
}
|
||||
|
||||
$item_key = $this->getCacheKey();
|
||||
if (!$this->cache->set($item_key, $value, $this->expire)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$set[$item_key] = $this->cache->getExpire($this->expire);
|
||||
return $this->cache->set($this->key, $set, $this->expire);
|
||||
}
|
||||
|
||||
public function del()
|
||||
{
|
||||
return $this->cache->del($this->key);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user