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:
@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user