本文整理汇总了PHP中JCache::get方法的典型用法代码示例。如果您正苦于以下问题:PHP JCache::get方法的具体用法?PHP JCache::get怎么用?PHP JCache::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JCache
的用法示例。
在下文中一共展示了JCache::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJoomlaMenuItems
/**
* Recupera una lista de los items de menu publicados en Joomla!
*
* @return array Lista de menùes recuperados
*/
function getJoomlaMenuItems()
{
$dbo =& JFactory::getDBO();
$query = 'SELECT ' . $dbo->nameQuote('m.id') . ', ' . $dbo->nameQuote('m.name') . ' FROM ' . $dbo->nameQuote('#__menu') . ' m' . ' WHERE ' . $dbo->nameQuote('published') . ' = 1';
$dbo->setQuery($query);
return $this->_cache->get(array($dbo, 'loadObjectList'), array());
}
示例2: checkCache
function checkCache()
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
if ($this->_recache) {
$this->_cache->remove($this->_cache_key);
return;
}
if ($app->isAdmin() || $this->isDisabled() || count($app->getMessageQueue()) || $user->get('admin') || $app->input->getMethod() !== 'GET') {
return;
}
$data = $this->_cache->get($this->_cache_key);
if (false === strpos($data, sprintf('cached:%d', $this->_cache_version))) {
// Logger::d('ERROR: Cache version mismatch');
return;
}
if ($data !== false) {
// Set cached body.
$app->setBody($data);
echo $app->toString($app->get('gzip'));
// Logger::d(__METHOD__.' from cache');
$app->close();
exit;
}
}
示例3: getCpMenuValues
/**
* Recupera una lista de los values asociados a un tag menu.
*
* @return array Lista de values recuperados
*/
function getCpMenuValues($field_id)
{
$tipo = $this->getTipo('menu');
$dbo =& JFactory::getDBO();
$query = 'SELECT ' . $dbo->nameQuote('v.id') . ', ' . $dbo->nameQuote('v.name') . ', ' . $dbo->nameQuote('v.label') . ' FROM ' . $dbo->nameQuote('#__custom_properties_values') . ' v' . ' INNER JOIN ' . $dbo->nameQuote('#__zonales_cp2tipotag') . ' tt' . ' ON ' . $dbo->nameQuote('tt.field_id') . ' = ' . $dbo->nameQuote('v.field_id') . ' AND ' . $dbo->nameQuote('tt.tipo_id') . ' = ' . $tipo->id . ' AND ' . $dbo->nameQuote('tt.field_id') . ' = ' . $field_id;
$dbo->setQuery($query);
return $this->_cache->get(array($dbo, 'loadObjectList'), array());
}
示例4: array
/**
* Recupera los datos desde el modelo (un solo registro)
*
* @param boolean $reload recargar datos desde bd o utilizar copia de la instancia
* @return Object registro especificado en la bd
*/
function &getData($reload = false, $customQuery = false)
{
if (empty($this->_data) || $reload) {
$query = $this->_buildQuery($customQuery);
$this->_db->setQuery($query);
//$this->_data = $this->_db->loadObject();
$this->_data = $this->_cache->get(array($this->_db, 'loadObject'), array());
}
if (!$this->_data) {
$this->_data =& $this->getTable();
}
return $this->_data;
}
示例5: getTableSchema
/**
* Retrieves the table schema information about the given table
*
* This function try to get the table schema from the cache. If it cannot be found the table schema will be
* retrieved from the database and stored in the cache.
*
* @param string $table A table name or a list of table names
* @return KDatabaseSchemaTable
*/
public function getTableSchema($table)
{
if (!isset($this->_table_schema[$table]) && isset($this->_cache)) {
$identifier = md5($this->getDatabase() . $table);
if (!($schema = $this->_cache->get($identifier))) {
$schema = parent::getTableSchema($table);
//Store the object in the cache
$this->_cache->store(serialize($schema), $identifier);
} else {
$schema = unserialize($schema);
}
$this->_table_schema[$table] = $schema;
}
return parent::getTableSchema($table);
}
示例6: _parse
/**
* Parse the template
*
* This function implements a caching mechanism when reading the template. If the template cannot be found in the
* cache it will be filtered and stored in the cache. Otherwise it will be loaded from the cache and returned
* directly.
*
* @param string The template content to parse
* @return void
*/
protected function _parse(&$content)
{
if (isset($this->_cache)) {
$identifier = md5($this->getPath());
if (!$this->_cache->get($identifier)) {
parent::_parse($content);
//Store the object in the cache
$this->_cache->store($content, $identifier);
} else {
$content = $this->_cache->get($identifier);
}
} else {
parent::_parse($content);
}
}
示例7: get
/**
* Get stored cached data by id and group
*
* @param string $id The cache data id
* @param string $group The cache data group
*
* @return mixed False on no result, cached object otherwise
*
* @since 11.1
*/
public function get()
{
$numargs = func_num_args();
if ($numargs <= 0) {
return false;
}
$id = func_get_arg(0);
$group = $numargs > 1 ? func_get_arg(1) : null;
$data = $this->cache->get($id, $group);
if ($data === false) {
$locktest = new stdClass();
$locktest->locked = null;
$locktest->locklooped = null;
$locktest = $this->cache->lock($id, $group);
if ($locktest->locked == true && $locktest->locklooped == true) {
$data = $this->cache->get($id, $group);
}
if ($locktest->locked == true) {
$this->cache->unlock($id, $group);
}
}
// Check again because we might get it from second attempt
if ($data !== false) {
$data = unserialize(trim($data));
// trim to fix unserialize errors
}
return $data;
}
示例8: getMenuValues
/**
* Recupera los valores del tag indicado
*
* @param int id identificador del tag
* @return array Arreglo de objetos value
*/
function getMenuValues($id, $eq = false)
{
if (is_null($id)) {
return null;
}
$dbo =& JFactory::getDBO();
$query = 'SELECT ' . $dbo->nameQuote('v.id') . ', ' . $dbo->nameQuote('v.name') . ', ' . $dbo->nameQuote('v.label') . ', ' . $dbo->nameQuote('jm.link') . ', ' . $dbo->nameQuote('zm.menu_id') . ($eq ? ', b.peso' : '') . ' FROM ' . $dbo->nameQuote('#__custom_properties_values') . ' v' . ' INNER JOIN ' . $dbo->nameQuote('#__zonales_menu') . ' zm' . ' ON ' . $dbo->nameQuote('zm.value_id') . ' = ' . $dbo->nameQuote('v.id') . ' INNER JOIN ' . $dbo->nameQuote('#__menu') . ' jm' . ' ON ' . $dbo->nameQuote('jm.id') . ' = ' . $dbo->nameQuote('zm.menu_id');
// ecualiza
if ($eq) {
require_once JPATH_BASE . DS . 'components' . DS . 'com_eqzonales' . DS . 'controllers' . DS . 'eq.php';
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_eqzonales' . DS . 'tables');
$ctrlEq = new EqZonalesControllerEq();
$ctrlEq->addModelPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_eqzonales' . DS . 'models');
// recupera ecualizador del usuario
$user =& JFactory::getUser();
$result = $ctrlEq->retrieveUserEqImpl($user->id);
if (!is_null($result) && !empty($result)) {
$eq = $result[0];
$query .= ' LEFT JOIN ' . $dbo->nameQuote('#__eqzonales_banda') . ' b' . ' ON ' . $dbo->nameQuote('v.id') . ' = ' . $dbo->nameQuote('b.cp_value_id') . ' AND ' . $dbo->nameQuote('b.eq_id') . ' = ' . $eq->eq->id;
}
}
// where
$query .= ' WHERE ' . $dbo->nameQuote('v.field_id') . ' = ' . $id;
// ordena según ecualización
if ($eq) {
$query .= ' ORDER BY b.peso DESC';
}
$dbo->setQuery($query);
return $this->_cache->get(array($dbo, 'loadObjectList'), array());
}
示例9: isOutputExpired
/**
* @param $checksum
*
* @return bool|mixed
*/
protected function isOutputExpired(RokBooster_Compressor_IGroup $group, $is_wrapped = true)
{
$oc = RokBooster_Compressor_OutputContainerFactory::create($group, $this->options);
if (!$oc->doesExist($is_wrapped)) {
return true;
}
if ($expired = $oc->isExpired($is_wrapped)) {
$files_changed = false;
if ($file_group = $this->file_info_cache->get($group->getChecksum() . '_fileinfo')) {
$file_group = unserialize($file_group);
/** @var $file RokBooster_Compressor_File */
foreach ($file_group as $file) {
if (file_exists($file->getPath()) && is_readable($file->getPath())) {
if ($file->hasChanged()) {
$files_changed = true;
break;
}
} else {
$this->file_info_cache->remove($group->getChecksum() . '_fileinfo');
$files_changed = true;
break;
}
}
} else {
$files_changed = true;
}
if (!$files_changed) {
$oc->setAsValid();
return false;
}
}
return $expired;
}
示例10: onJSolrSearchOptionLookup
/**
* A convenience event handler to obtain the text related to an option's
* value.
*
* The event cache's the options for quicker lookup and to reduce load on
* the database. Therefore, there may be some delay between new items
* being added to JReviews and what is retrieved by this event.
*
* @param string $value The option's value.
* @return string The text related to the option's value.
*/
public function onJSolrSearchOptionLookup($value)
{
$conf = JFactory::getConfig();
$options = array('defaultgroup' => 'plg_jsolrsearch_jreviews', 'cachebase' => $conf->getValue('config.cache_path'), 'lifetime' => $conf->getValue('config.cachetime') * 60, 'language' => $conf->getValue('config.language'), 'storage' => $conf->getValue('config.storage', 'file'));
$cache = new JCache($options);
$cache->setCaching(true);
if (!($list = json_decode($cache->get('options', $options['defaultgroup'])))) {
$database = JFactory::getDbo();
$query = $database->getQuery(true);
$query->select(array('text', 'value'))->from('#__jreviews_fieldoptions');
$database->setQuery($query);
$list = $database->loadObjectList();
// cache these options so we don't need to keep loading from db.
$cache->store(json_encode($list), $options['defaultgroup']);
}
$found = false;
$text = "";
while (!$found && ($item = current($list))) {
if ($item->value == $value) {
$found = true;
$text = $item->text;
}
next($list);
}
return $text;
}
示例11: get
/**
* Get the cached page data
*
* @access public
* @param string $id The cache data id
* @param string $group The cache data group
* @return boolean True if the cache is hit (false else)
* @since 1.5
*/
function get($id = false, $group = 'page')
{
// Initialize variables
$data = false;
// If an id is not given generate it from the request
if ($id == false) {
$id = $this->_makeId();
}
// If the etag matches the page id ... sent a no change header and exit : utilize browser cache
if (!headers_sent() && isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
$etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
if ($etag == $id) {
$browserCache = isset($this->_options['browsercache']) ? $this->_options['browsercache'] : false;
if ($browserCache) {
$this->_noChange();
}
}
}
// We got a cache hit... set the etag header and echo the page data
$data = parent::get($id, $group);
if ($data !== false) {
$this->_setEtag($id);
return $data;
}
// Set id and group placeholders
$this->_id = $id;
$this->_group = $group;
return false;
}
示例12: get
/**
* Get stored cached data by id and group
*
* @param string $id The cache data id
* @param string $group The cache data group
*
* @return mixed False on no result, cached object otherwise
*
* @since 11.1
*/
public function get($id, $group = null)
{
$data = false;
$data = $this->cache->get($id, $group);
if ($data === false)
{
$locktest = new stdClass;
$locktest->locked = null;
$locktest->locklooped = null;
$locktest = $this->cache->lock($id, $group);
if ($locktest->locked == true && $locktest->locklooped == true)
{
$data = $this->cache->get($id, $group);
}
if ($locktest->locked == true)
{
$this->cache->unlock($id, $group);
}
}
// Check again because we might get it from second attempt
if ($data !== false)
{
// Trim to fix unserialize errors
$data = unserialize(trim($data));
}
return $data;
}
示例13: testGc
/**
* Testing Gc().
*
* @return void
*/
public function testGc()
{
$this->object = JCache::getInstance('output', array('lifetime' => 2, 'defaultgroup' => ''));
$this->object->store(
'Now is the time for all good people to throw a party.',
42,
''
);
$this->object->store(
'And this is the cache that tries men\'s souls',
42,
''
);
sleep(5);
$this->object->gc();
$this->assertThat(
$this->object->get(42, ''),
$this->isFalse(),
'Should not retrieve the data properly'
);
$this->assertThat(
$this->object->get(42, ''),
$this->isFalse(),
'Should not retrieve the data properly'
);
}
示例14: isCacheExpired
/**
* @param $checksum
*
* @return bool|mixed
*/
protected function isCacheExpired($checksum)
{
if (!$this->cache->doesCacheExist($checksum)) {
return true;
}
if ($expired = $this->cache->isCacheExpired($checksum)) {
$files_changed = false;
if ($file_group = $this->file_info_cache->get($checksum . '_fileinfo')) {
$file_group = unserialize($file_group);
/** @var $file RokBooster_Compressor_File */
foreach ($file_group as $file) {
if (file_exists($file->getPath()) && is_readable($file->getPath())) {
if ($file->hasChanged()) {
$files_changed = true;
break;
}
} else {
$this->file_info_cache->remove($checksum . '_fileinfo');
$files_changed = true;
break;
}
}
} else {
$files_changed = true;
}
if (!$files_changed) {
$this->cache->setCacheAsValid($checksum);
return false;
}
}
return $expired;
}
示例15: testGc
/**
* Testing Gc().
*
* @medium
*
* @return void
*/
public function testGc()
{
$this->object = JCache::getInstance('output', array('lifetime' => 2, 'defaultgroup' => ''));
$this->object->store($this->testData_A, 42, '');
$this->object->store($this->testData_B, 43, '');
sleep(5);
$this->object->gc();
$this->assertFalse($this->object->get(42, ''));
$this->assertFalse($this->object->get(43, ''));
}