本文整理匯總了PHP中ViewManager::clear_all_cache方法的典型用法代碼示例。如果您正苦於以下問題:PHP ViewManager::clear_all_cache方法的具體用法?PHP ViewManager::clear_all_cache怎麽用?PHP ViewManager::clear_all_cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ViewManager
的用法示例。
在下文中一共展示了ViewManager::clear_all_cache方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: runRegisteredPluginsCrawl
/**
* Runs registered plugins' crawl function.
*
* About crawler exclusivity (mutex usage):
* When launched by an admin, no other user, admin or not, will be able to launch a crawl until this one is done.
* When launched by a non-admin, we first check that no admin run is under way, and if that's the case,
* we launch a crawl for the current user only.
* No user will be able to launch two crawls in parallel, but different non-admin users crawls can run in parallel.
* @throws UnauthorizedUserException If user is not logged in
* @throws CrawlerLockedException If a crawl is already in progress
* @throws InstallerException If ThinkUp is in the midst of a database upgrade
*/
public function runRegisteredPluginsCrawl()
{
if (!Session::isLoggedIn()) {
throw new UnauthorizedUserException('You need a valid session to launch the crawler.');
}
$mutex_dao = DAOFactory::getDAO('MutexDAO');
$owner_dao = DAOFactory::getDAO('OwnerDAO');
$owner = $owner_dao->getByEmail(Session::getLoggedInUser());
if (empty($owner)) {
throw new UnauthorizedUserException('You need a valid session to launch the crawler.');
}
// are we in an upgrading state
if (UpgradeDatabaseController::isUpgrading(true, 'Crawler')) {
throw new InstallerException("ThinkUp needs a database migration, so we are unable to run the crawler.");
}
$global_mutex_name = self::GLOBAL_MUTEX;
// Everyone needs to check the global mutex
$lock_successful = 1;
$mutex_dao->getMutex($global_mutex_name);
// 1
if ($lock_successful) {
// Global mutex was free, which means no admin crawls are under way
if ($owner->is_admin) {
// Nothing more needs to be done, since admins use the global mutex
$mutex_name = $global_mutex_name;
} else {
// User is a non-admin; let's use a user mutex.
$mutex_name = 'crawler-' . $owner->id;
$lock_successful = $mutex_dao->getMutex($mutex_name);
$mutex_dao->releaseMutex($global_mutex_name);
}
}
if ($lock_successful) {
$this->emitObjectFunction('crawl');
$mutex_dao->releaseMutex($mutex_name);
//clear cache so that insight stream updates
$v_mgr = new ViewManager();
$v_mgr->clear_all_cache();
} else {
throw new CrawlerLockedException("Error starting crawler; another crawl is already in progress.");
}
}