/** * Constructor */ private function __construct() { return; $memcache = \Core\Memcache::getInstance(); $this->_acl = $memcache->get('acl_cache'); if (!$this->_acl) { $sql = 'SELECT r.title, CONCAT_WS(\':\', res.module, res.controller, res.action) AS resource, a.allow FROM `admin_roles` r INNER JOIN `admin_users_access` a ON a.admin_role_id=r.id'; $sql .= ' INNER JOIN `acl_resources` res ON res.id = a.acl_resource_id'; $stm = $aclData = \Core\Db\Connector::getInstance()->getConnection()->prepare($sql); $stm->execute(); $aclData = $stm->fetchAll(\PDO::FETCH_ASSOC); foreach ($aclData as $nfo) { $this->_acl[$nfo['title']][$nfo['resource']] = $nfo['allow']; } $memcache->set('acl_cache', $this->_acl); } }
/** * @param Config $config * * @return \Doctrine\Common\Cache\CacheProvider * @throws \OutOfBoundsException */ public function getCache($config) { $type = $config->get('type'); switch ($type) { case 'memcache': $memcache = new \Memcache(); $memcache->connect($config->get('config.host'), $config->get('config.port')); $cache = new \Doctrine\Common\Cache\MemcacheCache(); $cache->setMemcache($memcache); break; case 'xcache': $cache = new \Doctrine\Common\Cache\XCacheCache(); break; case 'apc': $cache = new \Doctrine\Common\Cache\ApcCache(); break; case 'array': $cache = new \Doctrine\Common\Cache\ArrayCache(); break; default: throw new \OutOfBoundsException(sprintf("Unsupported cache type: '%s'", $type)); break; } return $cache; }