本文整理汇总了PHP中CCache类的典型用法代码示例。如果您正苦于以下问题:PHP CCache类的具体用法?PHP CCache怎么用?PHP CCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
/**
* Teardown environment
*
* @return void
*/
protected function tearDown()
{
$cache = new CCache();
$cache->setDir(CACHE_PATH);
$this->removeFilesInCacheDir();
$cache->removeSubdir(self::DUMMY);
}
示例2: loadPageXml
private function loadPageXml($xmlFile)
{
/* init */
$file = CONTROLLER_PATH . $xmlFile;
$this->m_fileName = $xmlFile;
$cCache = new CCache($this->m_cConfig, $file);
$retXml = array();
/**
* Can it use cache? */
if ($cCache->useCache() == true) {
$retXml = $cCache->getCache();
}
/**
* Read the xml file and cache it */
else {
$xmlData = new CXmlController($file);
$xmlData->setDefaultType("string-iso");
$xmlData->startParser();
$retXml = $xmlData->getXmlData();
/* cache */
$cCache->setCache($retXml);
}
return $retXml;
}
示例3: loadUrl
public function loadUrl()
{
/* init cache object */
$cCache = new CCache($this->m_cConfig, $this->m_xmlFile);
/* if it can use the cache, I use it or I cache it! */
if ($cCache->useCache == true) {
$urlX = $cCache->getCache();
}
/**
* Cache config */
else {
$xmlData = new CXmlController($this->m_xmlFile);
$xmlData->setDefaultType("string-utf8");
$xmlData->startParser();
$urlX = $xmlData->getXmlData();
/* cache it for next one */
$cCache->setCache($urlX);
}
/* erstelle m_urlXml */
$this->assocUrl($urlX);
}
示例4: getCacheProxy
/**
* @return CCache
*/
protected function getCacheProxy()
{
if (is_null($this->_cacheProxy)) {
$this->_cacheProxy = Yii::createComponent($this->cache);
$this->_cacheProxy->init();
}
return $this->_cacheProxy;
}
示例5: render
protected function render($view, $controller = "site", $arrResult = array(), $template = TEMPLATE)
{
$cache = new CCache(604800);
$flagCache = false;
if (!$cache->cacheExists(CApp::getHashCurPage()) && false) {
$flagCache = true;
$cache->startCache();
}
include_once $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/header.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/views/" . strtolower($controller) . "/" . $view . ".php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/footer.php";
if ($flagCache) {
$cache->writeCache(filterGetValue(CApp::getHashCurPage()));
}
}
示例6: __construct
public function __construct(&$db)
{
parent::__construct('#__community_config', 'name', $db);
// Get cache object.
$oCache = CCache::inject($this);
// Remove all cache on configuration change.
$oCache->addMethod(CCache::METHOD_STORE, CCache::ACTION_REMOVE, COMMUNITY_CACHE_TAG_ALL);
}
示例7: deleteCache
/**
* Delete cahche on request.
**/
function deleteCache($method)
{
if ($oCache = CCache::load($this)) {
if ($aSetting = $oCache->getMethod($method)) {
$oCache->remove($aSetting['tag']);
}
}
}
示例8: CTableVideosCategory
/**
* Constructor
*/
function CTableVideosCategory(&$db)
{
parent::__construct('#__community_videos_category', 'id', $db);
// Get cache object.
$oCache = CCache::inject($this);
// Remove video cache on every delete & store
$oCache->addMethod(CCache::METHOD_DEL, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_VIDEOS_CAT));
$oCache->addMethod(CCache::METHOD_STORE, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_VIDEOS_CAT));
}
示例9: render
protected function render($view, $controller = "site", $arrResult = [], $template = null)
{
if ($template == null) {
$template = CApp::settings('APPLICATION')->templates['default'];
}
$cache = new CCache(604800);
$flagCache = false;
if (!$cache->cacheExists(CApp::getHashCurPage()) && CApp::settings("APPLICATION")->settings['cache_on']) {
$flagCache = true;
$cache->startCache();
}
include $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/header.php";
include $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/views/" . strtolower($controller) . "/" . $view . ".php";
include $_SERVER["DOCUMENT_ROOT"] . "/engine/templates/" . $template . "/footer.php";
if ($flagCache) {
$cache->writeCache(filterGetValue(CApp::getHashCurPage()));
}
}
示例10: __construct
/**
* Constructor
*/
public function __construct(&$db)
{
parent::__construct('#__community_events', 'id', $db);
// Get cache object.
$oCache = CCache::inject($this);
// Remove video cache on every delete & store
$oCache->addMethod(CCache::METHOD_DEL, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_EVENTS, COMMUNITY_CACHE_TAG_EVENTS_CAT));
$oCache->addMethod(CCache::METHOD_STORE, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_EVENTS, COMMUNITY_CACHE_TAG_EVENTS_CAT));
}
示例11: __construct
/**
* Constructor
*/
public function __construct(&$db)
{
parent::__construct('#__community_groups_category', 'id', $db);
// Get cache object.
$oCache = CCache::inject($this);
// Remove groups category cache on every delete & store
$oCache->addMethod(CCache::METHOD_DEL, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_GROUPS_CAT));
$oCache->addMethod(CCache::METHOD_STORE, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_GROUPS_CAT));
}
示例12: __construct
/**
* Constructor
*/
function __construct(&$db)
{
parent::__construct('#__community_photos_albums', 'id', $db);
// Get cache object.
$oCache = CCache::inject($this);
// Remove photo cache on album delete.
$oCache->addMethod(CCache::METHOD_DEL, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_PHOTOS));
$oCache->addMethod(CCache::METHOD_STORE, CCache::ACTION_REMOVE, array(COMMUNITY_CACHE_TAG_ALBUMS));
}
示例13: loadConfig
public function loadConfig($xmlFile)
{
$xmlFile = $this->m_path + $xmlFile;
/* init cache object for config file */
$cCache = new CCache($this->m_cConf, $xmlFile);
/* if I can use the cache, I use it or I cache it! */
if ($cCache->useCache == true) {
$this->m_config = $cCache->getCache();
}
/**
* Cache config */
else {
parent::loadConfig($xmlFile);
$cCache->setCache($this->m_config);
}
}
示例14: init
/**
* Initializes this application component.
* This method is required by the {@link IApplicationComponent} interface.
* It checks the availability of eAccelerator.
* @throws CException if eAccelerator extension is not loaded, is disabled or the cache functions are not compiled in.
*/
public function init()
{
parent::init();
if (!function_exists('eaccelerator_get')) {
throw new CException(Yii::t('yii', 'CEAcceleratorCache requires PHP eAccelerator extension to be loaded, enabled or compiled with the "--with-eaccelerator-shared-memory" option.'));
}
}
示例15: init
/**
* Initializes this application component.
* This method is required by the {@link IApplicationComponent} interface.
* It checks the availability of memcache.
* @throws CException if memcache extension is not loaded or is disabled.
*/
public function init()
{
parent::init();
if (!function_exists('xcache_isset')) {
throw new CException(Yii::t('yii', 'CXCache requires PHP XCache extension to be loaded.'));
}
}