Memcache caching, #18

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@120 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
pzinovkin
2010-03-05 18:41:02 +00:00
parent 00259cfe93
commit 2d7f5391f8
6 changed files with 287 additions and 21 deletions

View File

@ -22,19 +22,25 @@ abstract class Model
*/
protected $db;
/**
* Cache instance
*
* @var Cache
*/
protected $cache;
protected $table;
protected $connection = 'default';
protected $key = 'id';
protected $key = 'id';
public function __construct()
{
$this->db = Db::connect($this->connection);
}
/**
* @return int
*/
@ -123,14 +129,25 @@ abstract class Model
}
/**
* @param bool $autoescape
* @param bool $autoindent
* @return string
*/
public function table($autoescape = true)
protected function table($autoindent = true)
{
if (!$this->table) {
$this->table = substr(strtolower(get_class($this)), 0, -5/*strlen('Model')*/);
}
return $autoescape ? $this->identify($this->table) : $this->table;
return $autoindent ? $this->identify($this->table) : $this->table;
}
}
/**
* @return Cache
*/
protected function cache()
{
if (!$this->cache) {
$this->cache = Cacher::get(Config::get(__CLASS__, 'MemcacheCache'));
}
return $this->cache;
}
}