12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace Qii\Driver;
- trait traitCache
- {
- public $cache;
- /**
- * 设置Cache
- *
- * @param String $cache
- * @param Array $policy
- */
- final public function setCache($cache, $policy)
- {
- \Qii\Autoloader\Import::requires(Qii_DIR . DS . 'Qii' . DS . 'Cache.php');
- $this->cache = \Qii\Autoloader\Psr4::loadClass('\Qii\Cache', $cache)->initialization($policy);//载入cache类文件
- }
- /**
- * 缓存内容
- *
- * @param String $id
- * @param Array $value
- * @return Bool
- */
- final public function cache($id, $value)
- {
- return $this->cache->set($id, $value);
- }
- /**
- * 获取缓存的类
- */
- final public function getCache()
- {
- return $this->cache;
- }
- /**
- * 获取缓存内容
- *
- * @param String $id
- * @return Array
- */
- final public function getCacheData($id)
- {
- return $this->cache->get($id);
- }
- }
|