本文整理汇总了PHP中CacheHandler类的典型用法代码示例。如果您正苦于以下问题:PHP CacheHandler类的具体用法?PHP CacheHandler怎么用?PHP CacheHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CacheHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Returns the current template directory
*
* @since 1.0
* @see get_option
* @todo This is dirrrty dirrrty code. Fix ASAP.
*
* @param string $view Name of the current view
* @param string $prefix String to prefix to the cache ID, defaults to template name
* @return string
*/
public static function load($view = 'chrono', $prefix = '')
{
if (empty($prefix)) {
$prefix = get_option('template');
}
$current = Templates::get_current();
$view_file = $view . '.php';
$cache = new CacheHandler();
$cache->begin_caching($prefix . $_SERVER['REQUEST_URI']);
if (file_exists($current['Template Dir'] . '/' . $view_file)) {
require_once $current['Template Dir'] . '/' . $view_file;
} else {
require_once $current['Template Dir'] . '/index.php';
}
$cache->end_caching($prefix . $_SERVER['REQUEST_URI']);
}
示例2: read
function read($session_key)
{
if (!$session_key || !$this->session_started) {
return;
}
$oCacheHandler =& CacheHandler::getInstance('object');
if ($oCacheHandler->isSupport()) {
$cache_key = 'object:' . $session_key;
$output->data = $oCacheHandler->get($cache_key);
}
if (!$output->data) {
$args->session_key = $session_key;
$columnList = array('session_key', 'cur_mid', 'val');
$output = executeQuery('session.getSession', $args, $columnList);
// Confirm there is a table created if read error occurs
if (!$output->toBool()) {
$oDB =& DB::getInstance();
if (!$oDB->isTableExists('session')) {
$oDB->createTableByXmlFile($this->module_path . 'schemas/session.xml');
}
if (!$oDB->isColumnExists("session", "cur_mid")) {
$oDB->addColumn('session', "cur_mid", "varchar", 128);
}
$output = executeQuery('session.getSession', $args);
}
// Check if there is a table created in case there is no "cur_mid" value in the sessions information
if (!isset($output->data->cur_mid)) {
$oDB =& DB::getInstance();
if (!$oDB->isColumnExists("session", "cur_mid")) {
$oDB->addColumn('session', "cur_mid", "varchar", 128);
}
}
}
return $output->data->val;
}
示例3: isInsertedTodayStatus
/**
* Check if a row of today's counter status exists
*
* @param integer $site_srl Site_srl
* @return bool
*/
function isInsertedTodayStatus($site_srl = 0)
{
$args = new stdClass();
$args->regdate = date('Ymd');
$insertedTodayStatus = false;
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if ($oCacheHandler->isSupport()) {
$cache_key = 'counter:insertedTodayStatus:' . $site_srl . '_' . $args->regdate;
$insertedTodayStatus = $oCacheHandler->get($cache_key);
}
if ($insertedTodayStatus === false) {
if ($site_srl) {
$args->site_srl = $site_srl;
$output = executeQuery('counter.getSiteTodayStatus', $args);
} else {
$output = executeQuery('counter.getTodayStatus', $args);
}
$insertedTodayStatus = !!$output->data->count;
if ($insertedTodayStatus && $oCacheHandler->isSupport()) {
$oCacheHandler->put($cache_key, TRUE);
$_old_date = date('Ymd', strtotime('-1 day'));
$oCacheHandler->delete('counter:insertedTodayStatus:' . $site_srl . '_' . $_old_date);
}
}
return $insertedTodayStatus;
}
示例4: getLayout
/**
* Get one of layout information created in the DB
* Return DB info + XML info of the generated layout
* @param int $layout_srl
* @return object info of layout
**/
function getLayout($layout_srl)
{
// cache controll
$oCacheHandler =& CacheHandler::getInstance('object');
if ($oCacheHandler->isSupport()) {
$cache_key = 'object:' . $layout_srl;
$layout_info = $oCacheHandler->get($cache_key);
}
if (!$layout_info) {
// Get information from the DB
$args->layout_srl = $layout_srl;
$output = executeQuery('layout.getLayout', $args);
if (!$output->data) {
return;
}
// Return xml file informaton after listing up the layout and extra_vars
$layout_info = $this->getLayoutInfo($layout, $output->data, $output->data->layout_type);
// If deleted layout files, delete layout instance
// if (!$layout_info) {
// $oLayoutController = &getAdminController('layout');
// $oLayoutController->deleteLayout($layout_srl);
// return;
// }
//insert in cache
if ($oCacheHandler->isSupport()) {
$oCacheHandler->put($cache_key, $layout_info);
}
}
return $layout_info;
}
示例5: procAdminRecompileCacheFile
/**
* Regenerate all cache files
* @return void
*/
function procAdminRecompileCacheFile()
{
// rename cache dir
$temp_cache_dir = './files/cache_' . $_SERVER['REQUEST_TIME'];
FileHandler::rename('./files/cache', $temp_cache_dir);
FileHandler::makeDir('./files/cache');
// remove module extend cache
FileHandler::removeFile(_XE_PATH_ . 'files/config/module_extend.php');
// remove debug files
FileHandler::removeFile(_XE_PATH_ . 'files/_debug_message.php');
FileHandler::removeFile(_XE_PATH_ . 'files/_debug_db_query.php');
FileHandler::removeFile(_XE_PATH_ . 'files/_db_slow_query.php');
$oModuleModel = getModel('module');
$module_list = $oModuleModel->getModuleList();
// call recompileCache for each module
foreach ($module_list as $module) {
$oModule = NULL;
$oModule = getClass($module->module);
if (method_exists($oModule, 'recompileCache')) {
$oModule->recompileCache();
}
}
// remove cache
$truncated = array();
$oObjectCacheHandler = CacheHandler::getInstance('object');
$oTemplateCacheHandler = CacheHandler::getInstance('template');
if ($oObjectCacheHandler->isSupport()) {
$truncated[] = $oObjectCacheHandler->truncate();
}
if ($oTemplateCacheHandler->isSupport()) {
$truncated[] = $oTemplateCacheHandler->truncate();
}
if (count($truncated) && in_array(FALSE, $truncated)) {
return new Object(-1, 'msg_self_restart_cache_engine');
}
// remove cache dir
$tmp_cache_list = FileHandler::readDir('./files', '/(^cache_[0-9]+)/');
if ($tmp_cache_list) {
foreach ($tmp_cache_list as $tmp_dir) {
if ($tmp_dir) {
FileHandler::removeDir('./files/' . $tmp_dir);
}
}
}
// remove duplicate indexes (only for CUBRID)
$db_type = Context::getDBType();
if ($db_type == 'cubrid') {
$db = DB::getInstance();
$db->deleteDuplicateIndexes();
}
// check autoinstall packages
$oAutoinstallAdminController = getAdminController('autoinstall');
$oAutoinstallAdminController->checkInstalled();
$this->setMessage('success_updated');
}
示例6: procAdminRecompileCacheFile
/**
* Regenerate all cache files
* @return void
*/
function procAdminRecompileCacheFile()
{
// rename cache dir
$temp_cache_dir = './files/cache_' . time();
FileHandler::rename('./files/cache', $temp_cache_dir);
FileHandler::makeDir('./files/cache');
// remove debug files
FileHandler::removeFile(_XE_PATH_ . 'files/_debug_message.php');
FileHandler::removeFile(_XE_PATH_ . 'files/_debug_db_query.php');
FileHandler::removeFile(_XE_PATH_ . 'files/_db_slow_query.php');
$oModuleModel =& getModel('module');
$module_list = $oModuleModel->getModuleList();
// call recompileCache for each module
foreach ($module_list as $module) {
$oModule = null;
$oModule =& getClass($module->module);
if (method_exists($oModule, 'recompileCache')) {
$oModule->recompileCache();
}
}
// remove cache
$truncated = array();
$oObjectCacheHandler =& CacheHandler::getInstance('object');
$oTemplateCacheHandler =& CacheHandler::getInstance('template');
if ($oObjectCacheHandler->isSupport()) {
$truncated[] = $oObjectCacheHandler->truncate();
}
if ($oTemplateCacheHandler->isSupport()) {
$truncated[] = $oTemplateCacheHandler->truncate();
}
if (count($truncated) && in_array(false, $truncated)) {
return new Object(-1, 'msg_self_restart_cache_engine');
}
// remove cache dir
$tmp_cache_list = FileHandler::readDir('./files', '/(^cache_[0-9]+)/');
if ($tmp_cache_list) {
foreach ($tmp_cache_list as $tmp_dir) {
if ($tmp_dir) {
FileHandler::removeDir('./files/' . $tmp_dir);
}
}
}
// remove duplicate indexes (only for CUBRID)
$db_type =& Context::getDBType();
if ($db_type == 'cubrid') {
$db =& DB::getInstance();
$db->deleteDuplicateIndexes();
}
$this->setMessage('success_updated');
}
示例7: clearSumCache
function clearSumCache()
{
if ($_POST['option_clear_sum'] == 'on') {
$qry = DBFactory::getDBQuery();
$qry->execute("DELETE FROM kb3_sum_alliance");
$qry->execute("DELETE FROM kb3_sum_corp");
$qry->execute("DELETE FROM kb3_sum_pilot");
// Clear page and query cache as well since they also contain the
// summaries.
CacheHandler::removeByAge('SQL', 0, true);
CacheHandler::removeByAge('store', 0, true);
$_POST['option_clear_sum'] == 'off';
}
}
示例8: get
/**
* Get an image.
*
* Returns an image resource or false on failure. Fetches the image from
* CCP if needed.
* @param integer $id
* @param integer $size
* @return resource Image resource or false on failure.
*/
static function get($id, $size = 64)
{
$id = (int) $id;
$size = (int) $size;
if ($size != 32 && $size != 64) {
return false;
}
if (!$id) {
return imagecreatefromjpeg("img/portrait_0_{$size}.jpg");
}
// If it's in the cache then read it from there.
if (CacheHandler::exists("{$id}_{$size}.png", "img")) {
return imagecreatefrompng(CacheHandler::getInternal("{$id}_{$size}.png", "img"));
} else {
$img = self::fetchImage($id, $size);
imagepng($img, CacheHandler::getInternal("{$id}_{$size}.png", "img"));
return $img ? $img : imagecreatefromjpeg("img/portrait_0_{$size}.jpg");
}
}
示例9: procMagiccontentSetup
function procMagiccontentSetup()
{
$req = Context::getRequestVars();
$widget_sequence = $req->widget_sequence;
$is_complete = $req->is_complete;
unset($req->is_complete);
unset($req->widget_sequence);
unset($req->act);
foreach ($req as $key => $value) {
if ($value == '') {
unset($req->{$key});
}
}
$serialize_data = serialize($req);
$args = new stdClass();
$args->data = $serialize_data;
$args->widget_sequence = $widget_sequence;
$args->is_complete = $is_complete;
if ($is_complete == 1) {
$dargs = new stdClass();
$dargs->widget_sequence = $widget_sequence;
$dargs->is_complete = 0;
$output = executeQuery('magiccontent.deleteMagicContentData', $dargs);
}
$oMagiccontentModel =& getModel('magiccontent');
if ($oMagiccontentModel->getSetupData($widget_sequence, $is_complete) === false) {
$args->data_srl = getNextSequence();
$output = executeQuery('magiccontent.insertMagicContentData', $args);
} else {
$output = executeQuery('magiccontent.updateMagicContentData', $args);
}
$oCacheHandler = CacheHandler::getInstance('template');
if ($oCacheHandler->isSupport()) {
$key = 'widget_cache:' . $widget_sequence;
$oCacheHandler->delete($key);
}
$lang_type = Context::getLangType();
$cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $widget_sequence, $lang_type);
FileHandler::removeFile($cache_file);
return new Object(0, 'success');
}
示例10: _loadFromDB
/**
* Get data from database, and set the value to documentItem object
* @param bool $load_extra_vars
* @return void
*/
function _loadFromDB($load_extra_vars = true)
{
if (!$this->document_srl) {
return;
}
// cache controll
$oCacheHandler =& CacheHandler::getInstance('object');
if ($oCacheHandler->isSupport() && !count($this->columnList)) {
$cache_key = 'object_document_item:' . $this->document_srl;
$output = $oCacheHandler->get($cache_key);
}
if (!$output) {
$args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocument', $args, $this->columnList);
//insert in cache
if ($output->data->document_srl && $oCacheHandler->isSupport()) {
$oCacheHandler->put($cache_key, $output);
}
}
$this->setAttribute($output->data, $load_extra_vars);
}
示例11: procAjaxboardAdminDeleteAjaxboard
function procAjaxboardAdminDeleteAjaxboard()
{
$module_srl = Context::get('module_srl');
$oModuleController = getController('module');
$output = $oModuleController->deleteModule($module_srl);
if (!$output->toBool()) {
return $output;
}
$oCacheHandler = CacheHandler::getInstance('object', NULL, true);
if ($oCacheHandler->isSupport()) {
$object_key = 'module_ajaxboard_module_srls';
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->delete($cache_key);
$object_key = 'module_ajaxboard_linked_info';
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->delete($cache_key);
$object_key = 'module_ajaxboard_notify_info';
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->delete($cache_key);
}
$this->setMessage('success_deleted');
$this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAjaxboardAdminContent'));
}
示例12: _loadFromDB
/**
* Get data from database, and set the value to documentItem object
* @param bool $load_extra_vars
* @return void
*/
function _loadFromDB($load_extra_vars = true)
{
if (!$this->document_srl) {
return;
}
$document_item = false;
$cache_put = false;
$columnList = array();
$this->columnList = array();
// cache controll
$oCacheHandler = CacheHandler::getInstance('object');
if ($oCacheHandler->isSupport()) {
$cache_key = 'document_item:' . getNumberingPath($this->document_srl) . $this->document_srl;
$document_item = $oCacheHandler->get($cache_key);
if ($document_item !== false) {
$columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count');
}
}
$args = new stdClass();
$args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocument', $args, $columnList);
if ($document_item === false) {
$document_item = $output->data;
//insert in cache
if ($document_item && $oCacheHandler->isSupport()) {
$oCacheHandler->put($cache_key, $document_item);
}
} else {
$document_item->readed_count = $output->data->readed_count;
$document_item->voted_count = $output->data->voted_count;
$document_item->blamed_count = $output->data->blamed_count;
$document_item->comment_count = $output->data->comment_count;
$document_item->trackback_count = $output->data->trackback_count;
}
$this->setAttribute($document_item, $load_extra_vars);
}
示例13: deleteReview
/**
* @brief Delete comment
**/
function deleteReview($review_srl, $is_admin = false, $isMoveToTrash = false)
{
// create the comment model object
$oCommentModel =& getModel('store_review');
// check if comment already exists
$comment = $oCommentModel->getReview($review_srl);
if ($comment->review_srl != $review_srl) {
return new Object(-1, 'msg_invalid_request');
}
$item_srl = $comment->item_srl;
// call a trigger (before)
$output = ModuleHandler::triggerCall('store_review.deleteReview', 'before', $comment);
if (!$output->toBool()) {
return $output;
}
// check if child comment exists on the comment
$child_count = $oCommentModel->getChildCommentCount($review_srl);
if ($child_count > 0) {
return new Object(-1, 'fail_to_delete_have_children');
}
// check if permission is granted
if (!$is_admin && !$comment->isGranted()) {
return new Object(-1, 'msg_not_permitted');
}
// begin transaction
$oDB =& DB::getInstance();
$oDB->begin();
// Delete
$args->review_srl = $review_srl;
$output = executeQuery('store_review.deleteReview', $args);
if (!$output->toBool()) {
$oDB->rollback();
return $output;
}
$output = executeQuery('store_review.deleteReviewList', $args);
// update the number of comments
$comment_count = $oCommentModel->getReviewCount($item_srl);
/*
// create the controller object of the document
$oDocumentController = &getController('document');
// update comment count of the article posting
$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, null, false);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
*/
// call a trigger (after)
if ($output->toBool()) {
$trigger_output = ModuleHandler::triggerCall('store_review.deleteReview', 'after', $comment);
if (!$trigger_output->toBool()) {
$oDB->rollback();
return $trigger_output;
}
}
if (!$isMoveToTrash) {
$this->_deleteDeclaredComments($args);
$this->_deleteVotedComments($args);
}
// commit
$oDB->commit();
$output->add('item_srl', $item_srl);
//remove from cache
$oCacheHandler =& CacheHandler::getInstance('object');
if ($oCacheHandler->isSupport()) {
$oCacheHandler->invalidateGroupKey('commentList');
}
return $output;
}
示例14: getAttachInfo
/**
* @brief 자식 게시판 정보 반환
* @param int $module_srl
* @return array
*/
function getAttachInfo($module_srl)
{
if (!$module_srl) {
return array();
}
// 캐시 및 메모리 키값을 위한 해시 생성
$hash_id = md5('module_srl:' . $module_srl);
// 메모리에서 자식 게시판 정보 불러오기
$attach_info = $GLOBALS['__timeline__']['attach_info'][$hash_id];
// 메모리에 값이 없는 경우
if (is_null($attach_info)) {
$attach_info = FALSE;
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
// 캐시에서 자식 게시판 정보 불러오기
if ($oCacheHandler->isSupport()) {
$object_key = 'attach_info:' . $hash_id;
$cache_key = $oCacheHandler->getGroupKey('timeline', $object_key);
$attach_info = $oCacheHandler->get($cache_key);
}
// 저장된 캐시가 없거나 캐시를 사용할 수 없는 경우
if ($attach_info === FALSE) {
$attach_info = array();
$args = new stdClass();
$args->module_srl = $module_srl;
// DB에서 자식 게시판 정보 불러오기
$output = executeQueryArray('timeline.getAttachInfo', $args);
foreach ($output->data as $item) {
$attach_info[] = $item->target_srl;
}
// 캐시 저장
if ($oCacheHandler->isSupport()) {
$oCacheHandler->put($cache_key, $attach_info);
}
}
// 메모리 저장
$GLOBALS['__timeline__']['attach_info'][$hash_id] = $attach_info;
}
return $attach_info;
}
示例15: CacheHandler
<?php
require_once 'include/CacheHandler.php';
$cacheObj = new CacheHandler();
$results = $cacheObj->getFromCache();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB10lEQVQ4jX1TO2tUQRQelIgiGEt7CwVBhLvzzcZq73xnA4uQbht/QFBLFQnaWIivxcZXE8TCJkSw8REfnWkiRhEiCMEHgkERjGHnjKLCXovcXTfX3D1wiuGc78E3M8bkldVqm6O48bIOHs0fadWZslLighJZaXs8isRs29v9/4Fj6hIl/gwg+Nn2thUFV5R4ueKTnT1wliRDSrwaqF7HpUAEJTqROKmCuWVJhlfVPU4NBBPvlW6q7/xLiRNKzGTN5kajxJfB6vaYEp1CHl9VbCvSXTNB7HgUXFbiYiQmVTCvxO98+a4Sz9cP1Z0zxhgTPK4r8TQSt5VYUY+FSHdT6/asCs4Xw1TBfaV7sJZAbCu/yntKeyt4HFK6Z0pkeXhHYx2VSMwaY0ygPVJwYJeU9oUSn5S4kTX3bFKxE7nqR2OMaY8mu/P5jBIfig4mvtf2bQ/E2yiYXk3ZPenZ9u6N0j5W4rXW7I4g9nAxg0X17ngg3nUHfQ4+Z6N7ty5LMqyCeRUcVMFcjyD6SkM9Forp/iOwSzGtjuXOumEuRl9prHnOgS4NxJ0gOFNw0O2OEg+j4EB22mwo/VRZkgz1EwSiHWmvttPKrlLQukQjI1tiWh371nDbBu39BUbXq0cwWvsKAAAAAElFTkSuQmCC" rel="icon" type="image/x-icon" />
<title>Idea House</title>
<link rel="stylesheet" href="salvattore.css">
<link rel="stylesheet" href="normalize.css">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Idea House</h1>
<div id="timeline" data-columns="4">
<?php
foreach ($results as $result) {
?>
<div class="item line-<?php
echo $result['metadata']['data_source'];
?>