本文整理汇总了PHP中CacheHandler::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheHandler::getInstance方法的具体用法?PHP CacheHandler::getInstance怎么用?PHP CacheHandler::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheHandler
的用法示例。
在下文中一共展示了CacheHandler::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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');
}
示例5: 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');
}
示例6: 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');
}
示例7: _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);
}
示例8: 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'));
}
示例9: _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);
}
示例10: moduleUpdate
/**
* @brief Execute update
*/
function moduleUpdate()
{
$oDB =& DB::getInstance();
// 2008. 10. 27 module_part_config Add a multi-index to the table and check all information of module_configg
if (!$oDB->isIndexExists("module_part_config", "idx_module_part_config")) {
$oModuleModel = getModel('module');
$oModuleController = getController('module');
$modules = $oModuleModel->getModuleList();
foreach ($modules as $key => $module_info) {
$module = $module_info->module;
if (!in_array($module, array('point', 'trackback', 'layout', 'rss', 'file', 'comment', 'editor'))) {
continue;
}
$config = $oModuleModel->getModuleConfig($module);
$module_config = null;
switch ($module) {
case 'point':
$module_config = $config->module_point;
unset($config->module_point);
break;
case 'trackback':
case 'rss':
case 'file':
case 'comment':
case 'editor':
$module_config = $config->module_config;
unset($config->module_config);
if (is_array($module_config) && count($module_config)) {
foreach ($module_config as $key => $val) {
if (isset($module_config[$key]->module_srl)) {
unset($module_config[$key]->module_srl);
}
}
}
break;
case 'layout':
$tmp = $config->header_script;
if (is_array($tmp) && count($tmp)) {
foreach ($tmp as $k => $v) {
if (!$v && !trim($v)) {
continue;
}
$module_config[$k]->header_script = $v;
}
}
$config = null;
break;
}
$oModuleController->insertModuleConfig($module, $config);
if (is_array($module_config) && count($module_config)) {
foreach ($module_config as $module_srl => $module_part_config) {
$oModuleController->insertModulePartConfig($module, $module_srl, $module_part_config);
}
}
}
$oDB->addIndex("module_part_config", "idx_module_part_config", array("module", "module_srl"));
}
// 2008. 11. 13 drop index(unique_mid). Add a column and index on site_srl and mid columns
if (!$oDB->isIndexExists('modules', "idx_site_mid")) {
$oDB->dropIndex("modules", "unique_mid", true);
$oDB->addColumn('modules', 'site_srl', 'number', 11, 0, true);
$oDB->addIndex("modules", "idx_site_mid", array("site_srl", "mid"), true);
}
// document extra vars
if (!$oDB->isTableExists('document_extra_vars')) {
$oDB->createTableByXmlFile('./modules/document/schemas/document_extra_vars.xml');
}
if (!$oDB->isTableExists('document_extra_keys')) {
$oDB->createTableByXmlFile('./modules/document/schemas/document_extra_keys.xml');
}
// Move permission, skin info, extection info, admin ID of all modules to the table, grants
if ($oDB->isColumnExists('modules', 'grants')) {
$oModuleController = getController('module');
$oDocumentController = getController('document');
// Get a value of the current system language code
$lang_code = Context::getLangType();
// Get module_info of all modules
$output = executeQueryArray('module.getModuleInfos');
if (count($output->data)) {
foreach ($output->data as $module_info) {
// Separate information about permission granted to the module, extra vars, skin vars, super-admin's authority
$module_srl = trim($module_info->module_srl);
// grant an authority
$grants = unserialize($module_info->grants);
if ($grants) {
$oModuleController->insertModuleGrants($module_srl, $grants);
}
// Insert skin vars
$skin_vars = unserialize($module_info->skin_vars);
if ($skin_vars) {
$oModuleController->insertModuleSkinVars($module_srl, $skin_vars);
}
// Insert super admin's ID
$admin_id = trim($module_info->admin_id);
if ($admin_id && $admin_id != 'Array') {
$admin_ids = explode(',', $admin_id);
if (count($admin_id)) {
//.........这里部分代码省略.........
示例11: 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;
}
示例12: 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;
}
示例13: getReviewList
/**
* @brief get a comment list of the doc in corresponding woth document_srl.
**/
function getReviewList($module_srl, $item_srl, $page = 0, $is_admin = false, $count = 0)
{
// cache controll
$oCacheHandler =& CacheHandler::getInstance('object');
if ($oCacheHandler->isSupport()) {
$object_key = 'object:' . $item_srl . '_' . $page . '_' . ($is_admin ? 'Y' : 'N') . '_' . $count;
$cache_key = $oCacheHandler->getGroupKey('reviewList', $object_key);
$output = $oCacheHandler->get($cache_key);
}
if (!$output) {
/*
$oStoreModel = getModel('nstore_digital');
$oItemInfo = $oStoreModel->getItemInfo($item_srl);
$module_srl = $oItemInfo->module_srl;
*/
if (!$count) {
/*
$comment_config = $this->getCommentConfig($module_srl);
$comment_count = $comment_config->comment_count;
*/
if (!$comment_count) {
$comment_count = 50;
}
} else {
$comment_count = $count;
}
// get a very last page if no page exists
//if(!$page) $page = (int)( ($oDocument->getCommentCount()-1) / $comment_count) + 1;
if (!$page) {
$page = 1;
}
// get a list of comments
$args = new stdClass();
$args->item_srl = $item_srl;
$args->list_count = $comment_count;
$args->page = $page;
$args->page_count = 10;
$output = executeQueryArray('store_review.getReviewPageList', $args);
// return if an error occurs in the query results
if (!$output->toBool()) {
return $output;
}
// insert data into CommentPageList table if the number of results is different from stored comments
if (!$output->data) {
$this->fixCommentList($module_srl, $item_srl);
$output = executeQueryArray('store_review.getReviewPageList', $args);
if (!$output->toBool()) {
return $output;
}
}
//insert in cache
if ($oCacheHandler->isSupport()) {
$oCacheHandler->put($cache_key, $output);
}
}
return $output;
}
示例14: deleteAttachInfo
/**
* @brief 타임라인 게시판의 자식 게시판 삭제
* @param int $module_srl
* @return object
*/
function deleteAttachInfo($module_srl)
{
$args = new stdClass();
$args->module_srl = $module_srl;
// DB에서 자식 게시판 정보 삭제
$output = executeQuery('timeline.deleteAttachInfo', $args);
if ($output->toBool()) {
// 메모리에서 자식 게시판 정보 삭제
unset($GLOBALS['__timeline__']['attach_info']);
// 타임라인 모듈 캐시 삭제
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if ($oCacheHandler->isSupport()) {
$oCacheHandler->invalidateGroupKey('timeline');
}
}
return $output;
}
示例15: _clearMemberCache
function _clearMemberCache($member_srl, $site_srl = 0)
{
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if ($oCacheHandler->isSupport()) {
$object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_' . $site_srl;
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$oCacheHandler->delete($cache_key);
if ($site_srl !== 0) {
$object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_0';
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$oCacheHandler->delete($cache_key);
}
}
$oCacheHandler = CacheHandler::getInstance('object');
if ($oCacheHandler->isSupport()) {
$object_key = 'member_info:' . getNumberingPath($member_srl) . $member_srl;
$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
$oCacheHandler->delete($cache_key);
}
}