setAdapter( new $adapterClass($options)); } /** * * initialize application as singleton * * @param array $options configuration array * * @return \Cube\Cache */ public static function getInstance($options = array()) { if (!self::$_instance instanceof self) { self::$_instance = new self($options); } return self::$_instance; } /** * * get adapter * * @return Cache\Adapter\AbstractAdapter */ public function getAdapter() { return $this->_adapter; } /** * * set adapter * * @param Cache\Adapter\AbstractAdapter $adapter * * @return $this */ public function setAdapter($adapter) { $this->_adapter = $adapter; return $this; } /** * * get cache adapter queries flag * * @return bool */ public function getCacheQueries() { return $this->getAdapter()->getCacheQueries(); } /** * * get cache adapter metadata flag * * @return bool */ public function getCacheMetadata() { return $this->getAdapter()->getCacheMetadata(); } /** * * get cache adapter routes flag * * @return bool */ public function getCacheRoutes() { return $this->getAdapter()->getCacheRoutes(); } /** * * read data from cache * * @param string $name * @param string $type * * @return string|false */ public function read($name, $type) { return $this->getAdapter()->read($name, $type); } /** * * write data to cache * * @param string $name * @param string $type * @param mixed $data * @param int $expires * * @return $this */ public function write($name, $type, $data, $expires = null) { $this->getAdapter()->write($name, $type, $data, $expires); return $this; } }