本文整理汇总了PHP中JCache::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JCache::getInstance方法的具体用法?PHP JCache::getInstance怎么用?PHP JCache::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JCache
的用法示例。
在下文中一共展示了JCache::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
* @access protected
*/
protected function setUp()
{
include_once JPATH_PLATFORM . '/joomla/cache/cache.php';
include_once JPATH_PLATFORM . '/joomla/cache/controller.php';
include_once JPATH_PLATFORM . '/joomla/cache/controller/output.php';
$this->object = JCache::getInstance('output', array());
}
示例2: getCache
private function getCache()
{
$conf = JFactory::getConfig();
$options = array('defaultgroup' => '', 'storage' => $conf->get('cache_handler', ''), 'caching' => true, 'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache'));
$cache = JCache::getInstance('', $options);
return $cache;
}
示例3: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
* @access protected
*/
protected function setUp()
{
include_once JPATH_BASE . '/libraries/joomla/cache/cache.php';
include_once JPATH_BASE . '/libraries/joomla/cache/controller.php';
include_once JPATH_BASE . '/libraries/joomla/cache/controller/page.php';
$this->object = JCache::getInstance('page', array());
}
示例4: __construct
/**
* constructor
*/
function __construct(&$subject, $config)
{
global $_PROFILER;
$mainframe = JFactory::getApplication();
parent::__construct($subject, $config);
// if page cache is enabled.
if ($this->params->get('enable_cache', 0)) {
//Set the language in the class
$config =& JFactory::getConfig();
$options = array('cachebase' => JPATH_BASE . DS . 'cache', 'defaultgroup' => 'page', 'lifetime' => $this->params->get('cachetime', 15) * 60, 'enable_cache' => $this->params->get('enable_cache', 1) ? true : false, 'caching' => false, 'language' => $config->getValue('config.language', 'en-GB'));
file_put_contents(JPATH_BASE . DS . 'cache' . DS . 'time.txt', $this->params->get('cachetime', 15) * 60);
jimport('joomla.cache.cache');
$this->_cache = JCache::getInstance('page', $options);
$menu = $this->params->get('menu', '');
if ($menu != '') {
$this->_ItemidsCached = !is_array($menu) ? array($menu) : $menu;
}
}
// process clear cache from client request
if (JRequest::getVar('icespeed')) {
$this->processClearCacheRequest();
}
if ($mainframe->isAdmin()) {
// load js and css for proccessing client action.
PlgIceSpeedHelper::loadAdminMediaFiles('ice_speed');
// trigger clear cache: automatic clear cache after saved, applied.
if (JRequest::getVar('task') == 'apply' || JRequest::getVar('task') == 'save') {
$this->processClearCacheRequest();
}
}
}
示例5: cleanCache
/**
* Clean the cache.
* It also cleans the simplecustomrouter plugin cache, as the routes
* configured by this component are used by that plugin.
*
* This method is called when needed from parent models.
*
* @param string $group The cache group
* @param string $client_id The ID of the client
*/
protected function cleanCache($group = null, $client_id = 0)
{
$conf = JFactory::getConfig();
$options = array('defaultgroup' => 'simplecustomrouter', 'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache'));
$cache = JCache::getInstance('', $options)->clean();
parent::cleanCache($group, $client_id);
}
示例6: update
function update()
{
$currency = JRequest::getInt('hikashopcurrency', 0);
if (!empty($currency)) {
$app = JFactory::getApplication();
$app->setUserState(HIKASHOP_COMPONENT . '.currency_id', $currency);
$app->setUserState(HIKASHOP_COMPONENT . '.shipping_method', null);
$app->setUserState(HIKASHOP_COMPONENT . '.shipping_id', null);
$app->setUserState(HIKASHOP_COMPONENT . '.shipping_data', null);
$app->setUserState(HIKASHOP_COMPONENT . '.payment_method', null);
$app->setUserState(HIKASHOP_COMPONENT . '.payment_id', null);
$app->setUserState(HIKASHOP_COMPONENT . '.payment_data', null);
$url = JRequest::getString('return_url', '');
if (HIKASHOP_J30) {
$plugin = JPluginHelper::getPlugin('system', 'cache');
$params = new JRegistry(@$plugin->params);
$options = array('defaultgroup' => 'page', 'browsercache' => $params->get('browsercache', false), 'caching' => false);
$cache = JCache::getInstance('page', $options);
$cache->clean();
}
if (!empty($url)) {
if (hikashop_disallowUrlRedirect($url)) {
return false;
}
$app->redirect(urldecode($url));
}
}
return true;
}
示例7: getCss
function getCss ($path) {
$app = JFactory::getApplication();
// get vars last-modified
$vars_lm = $app->getUserState('vars_last_modified', 0);
// less file last-modified
$filepath = JPATH_ROOT.'/'.$path;
$less_lm = filemtime ($filepath);
// cache key
$key = md5 ($vars_lm.':'.$less_lm.':'.$path);
$group = 't3';
$cache = JCache::getInstance ('output', array('lifetime'=>1440));
// get cache
$data = $cache->get ($key, $group);
if ($data) {
return $data;
}
// not cached, build & store it
$data = $this->compileCss ($path)."\n";
$cache->store ($data, $key, $group);
return $data;
}
示例8: __construct
public function __construct($groupName)
{
$this->cache = JFactory::getCache($groupName, 'output');
$handler = 'output';
$options = array('storage' => 'file', 'defaultgroup' => $groupName, 'locking' => true, 'locktime' => 15, 'checkTime' => false, 'caching' => true);
$this->cache = JCache::getInstance($handler, $options);
}
示例9: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*/
protected function setUp()
{
parent::setUp();
include_once JPATH_PLATFORM . '/joomla/cache/cache.php';
include_once JPATH_PLATFORM . '/joomla/cache/controller.php';
include_once JPATH_PLATFORM . '/joomla/cache/controller/callback.php';
$this->object = JCache::getInstance('callback', array());
}
示例10: __construct
/**
* Constructor
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.0
*/
function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
//Set the language in the class
$config = JFactory::getConfig();
$options = array('defaultgroup' => 'page', 'browsercache' => $this->params->get('browsercache', false), 'caching' => false);
$this->_cache = JCache::getInstance('page', $options);
}
示例11: getCacheObject
/**
*
* @param type $type
* @return type
*/
public static function getCacheObject($type = 'callback', $lifetime = 86400)
{
$aOptions = array('defaultgroup' => 'plg_jch_optimize', 'checkTime' => TRUE, 'application' => 'site', 'language' => 'en-GB', 'cachebase' => JPATH_SITE . '/cache', 'storage' => 'file');
$oCache = JCache::getInstance($type, $aOptions);
$oCache->setCaching(TRUE);
$oCache->setLifeTime($lifetime);
return $oCache;
}
示例12: testConstruct
/**
* Test...
*
* @param string $type @todo
*
* @dataProvider provider
*
* @return void
*/
public function testConstruct($type)
{
$class = 'JCacheController' . ucfirst($type);
$cache =& JCache::getInstance($type);
$this->assertTrue($cache instanceof $class, 'Expecting= ' . $class . ' Returned= ' . get_class($cache));
$cache2 =& JCache::getInstance($type);
$this->assertTrue($cache !== $cache2, 'Type: ' . $type . ' Recieved the same instance twice');
}
示例13: __construct
/**
* Constructor.
*
* @param object &$subject The object to observe.
* @param array $config An optional associative array of configuration settings.
*
* @since 1.5
*/
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
// Set the language in the class.
$options = array('defaultgroup' => 'page', 'browsercache' => $this->params->get('browsercache', false), 'caching' => false);
$this->_cache = JCache::getInstance('page', $options);
$this->_cache_key = JUri::getInstance()->toString();
}
示例14: __construct
/**
* Constructor
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.0
*/
function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
//Set the language in the class
$config =& JFactory::getConfig();
$options = array('cachebase' => JPATH_BASE . DS . 'cache', 'defaultgroup' => 'page', 'lifetime' => $this->params->get('cachetime', 15) * 60, 'browsercache' => $this->params->get('browsercache', false), 'caching' => false, 'language' => $config->getValue('config.language', 'en-GB'));
jimport('joomla.cache.cache');
$this->_cache =& JCache::getInstance('page', $options);
}
示例15: _getCacheObject
/**
*
* @param type $type
* @return type
*/
private static function _getCacheObject($type, $lifetime)
{
if (static::${$type . 'Cache'} !== null) {
return static::${$type . 'Cache'};
}
$aOptions = array('defaultgroup' => 'plg_jch_optimize', 'checkTime' => TRUE, 'caching' => TRUE, 'application' => 'site', 'language' => 'en-GB', 'lifetime' => $lifetime);
static::${$type . 'Cache'} = JCache::getInstance($type, $aOptions);
return static::${$type . 'Cache'};
}