本文整理汇总了PHP中eZExpiryHandler类的典型用法代码示例。如果您正苦于以下问题:PHP eZExpiryHandler类的具体用法?PHP eZExpiryHandler怎么用?PHP eZExpiryHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZExpiryHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchIDListByUserID
static function fetchIDListByUserID($userID)
{
if ($userID == eZUser::anonymousId()) {
$userCache = eZUSer::getUserCacheByAnonymousId();
$ruleArray = $userCache['discount_rules'];
} else {
$http = eZHTTPTool::instance();
$handler = eZExpiryHandler::instance();
$expiredTimeStamp = 0;
if ($handler->hasTimestamp('user-discountrules-cache')) {
$expiredTimeStamp = $handler->timestamp('user-discountrules-cache');
}
$ruleTimestamp =& $http->sessionVariable('eZUserDiscountRulesTimestamp');
$ruleArray = false;
// check for cached version in session
if ($ruleTimestamp > $expiredTimeStamp) {
if ($http->hasSessionVariable('eZUserDiscountRules' . $userID)) {
$ruleArray =& $http->sessionVariable('eZUserDiscountRules' . $userID);
}
}
if (!is_array($ruleArray)) {
$ruleArray = self::generateIDListByUserID((int) $userID);
$http->setSessionVariable('eZUserDiscountRules' . $userID, $ruleArray);
$http->setSessionVariable('eZUserDiscountRulesTimestamp', time());
}
}
$rules = array();
foreach ($ruleArray as $ruleRow) {
$rules[] = $ruleRow['id'];
}
return $rules;
}
示例2: handle
static function handle( $cachePath, $nodeID, $ttl, $useGlobalExpiry = true )
{
$globalExpiryTime = -1;
eZExpiryHandler::registerShutdownFunction();
if ( $useGlobalExpiry )
{
$globalExpiryTime = eZExpiryHandler::getTimestamp( 'template-block-cache', -1 );
}
$cacheHandler = eZClusterFileHandler::instance( $cachePath );
$subtreeExpiry = -1;
// Perform an extra check if the DB handler is in use,
// get the modified_subnode value from the specified node ($nodeID)
// and use it as an extra expiry value.
if ( $cacheHandler instanceof eZDBFileHandler or $cacheHandler instanceof eZDFSFileHandler )
{
$subtreeExpiry = eZTemplateCacheBlock::getSubtreeModification( $nodeID );
}
$globalExpiryTime = max( eZExpiryHandler::getTimestamp( 'global-template-block-cache', -1 ), // This expiry value is the true global expiry for cache-blocks
$globalExpiryTime,
$subtreeExpiry );
if ( $ttl == 0 )
$ttl = -1;
return array( &$cacheHandler,
$cacheHandler->processCache( array( 'eZTemplateCacheBlock', 'retrieveContent' ), null,
$ttl, $globalExpiryTime ) );
}
示例3: clearCache
/**
* Force Route cache expiration,
* so that APC cache will be flushed and regenerated next REST call
*/
public static function clearCache()
{
$expiryHandler = eZExpiryHandler::instance();
if ($expiryHandler->hasTimestamp(ezpRestRouter::ROUTE_CACHE_KEY)) {
$expiryHandler->setTimestamp(ezpRestRouter::ROUTE_CACHE_KEY, 0);
$expiryHandler->store();
}
}
示例4: testCanRestore
/**
* Test scenario for issue #014897: Object/class name pattern and cache issues [patch]
*
* @result $phpCache->canRestore() returns true
* @expected $phpCache->canRestore() should return false
*
* @link http://issues.ez.no/14897
*/
public function testCanRestore()
{
$db = eZDB::instance();
$dbName = md5($db->DB);
$cacheDir = eZSys::cacheDirectory();
$phpCache = new eZPHPCreator($cacheDir, 'classidentifiers_' . $dbName . '.php', '', array('clustering' => 'classidentifiers'));
$handler = eZExpiryHandler::instance();
$expiryTime = 0;
if ($handler->hasTimestamp('class-identifier-cache')) {
$expiryTime = $handler->timestamp('class-identifier-cache');
}
$this->assertFalse($phpCache->canRestore($expiryTime));
}
示例5: testIssue15263
/**
* Regression test for issue #15263
* Content object name/url of imported content classes aren't generated correctly
*
* @url http://issues.ez.no/15263
*
* @outline
* 1) Expire and force generation of class attribute cache
* 2) Load a test package
* 3) Install the package
* 4) Publish an object of the imported class
* 5) The object name / url alias shouldn't be the expected one
**/
public function testIssue15263()
{
$adminUser = eZUser::fetchByName('admin');
$previousUser = eZUser::currentUser();
eZUser::setCurrentlyLoggedInUser($adminUser, $adminUser->attribute('contentobject_id'));
// 1) Expire and force generation of class attribute cache
$handler = eZExpiryHandler::instance();
$handler->setTimestamp('class-identifier-cache', time() - 1);
$handler->store();
eZContentClassAttribute::classAttributeIdentifierByID(1);
// 1) Load a test package
$packageName = 'ezpackage_regression_testIssue15223.ezpkg';
$packageFilename = dirname(__FILE__) . DIRECTORY_SEPARATOR . $packageName;
$packageImportTried = false;
while (!$packageImportTried) {
$package = eZPackage::import($packageFilename, $packageName);
if (!$package instanceof eZPackage) {
if ($package === eZPackage::STATUS_ALREADY_EXISTS) {
$packageToRemove = eZPackage::fetch($packageName);
$packageToRemove->remove();
} else {
self::fail("An error occured loading the package '{$packageFilename}'");
}
}
$packageImportTried = true;
}
// 2) Install the package
$installParameters = array('site_access_map' => array('*' => false), 'top_nodes_map' => array('*' => 2), 'design_map' => array('*' => false), 'restore_dates' => true, 'user_id' => $adminUser->attribute('contentobject_id'), 'non-interactive' => true, 'language_map' => $package->defaultLanguageMap());
$result = $package->install($installParameters);
// 3) Publish an object of the imported class
$object = new ezpObject('test_issue_15523', 2, $adminUser->attribute('contentobject_id'), 1);
$object->myname = __METHOD__;
$object->myothername = __METHOD__;
$publishedObjectID = $object->publish();
unset($object);
// 4) Test data from the publish object
$publishedNodeArray = eZContentObjectTreeNode::fetchByContentObjectID($publishedObjectID);
if (count($publishedNodeArray) != 1) {
$this->fail("An error occured fetching node for object #{$publishedObjectID}");
}
$publishedNode = $publishedNodeArray[0];
if (!$publishedNode instanceof eZContentObjectTreeNode) {
$this->fail("An error occured fetching node for object #{$publishedObjectID}");
} else {
$this->assertEquals("eZPackageRegression::testIssue15263", $publishedNode->attribute('name'));
$this->assertEquals("eZPackageRegression-testIssue15263", $publishedNode->attribute('url_alias'));
}
// Remove the installed package & restore the logged in user
$package->remove();
eZUser::setCurrentlyLoggedInUser($previousUser, $previousUser->attribute('contentobject_id'));
}
示例6: fetchContentTreeMenuExpiry
public static function fetchContentTreeMenuExpiry()
{
$expiryHandler = eZExpiryHandler::instance();
if (!$expiryHandler->hasTimestamp('content-tree-menu')) {
$expiryHandler->setTimestamp('content-tree-menu', time());
$expiryHandler->store();
}
return array('result' => $expiryHandler->timestamp('content-tree-menu'));
}
示例7: shutdown
/**
* Runs the shutdown process
*/
protected function shutdown($reInitialize = true)
{
eZExecution::cleanup();
eZExecution::setCleanExit();
eZExpiryHandler::shutdown();
if ($reInitialize) {
$this->isInitialized = false;
}
}
示例8: expiryTimestamp
/**
* Returns the expiry timestamp for wildcard cache from eZExpiryHandler
* @return int|bool the timestamp if set, false otherwise
*/
protected static function expiryTimestamp()
{
$handler = eZExpiryHandler::instance();
if ( $handler->hasTimestamp( self::CACHE_SIGNATURE ) )
{
$ret = $handler->timestamp( self::CACHE_SIGNATURE );
}
else
{
$ret = false;
}
return $ret;
}
示例9: clearActiveExtensions
/**
* Clears active extensions list cache
*/
static function clearActiveExtensions($cacheItem)
{
eZExpiryHandler::registerShutdownFunction();
$handler = eZExpiryHandler::instance();
$handler->setTimestamp($cacheItem['expiry-key'], time());
$handler->store();
eZExtension::clearActiveExtensionsMemoryCache();
}
示例10: limitations
/**
* Returns an array of limitations useable by the policy system
*
* @return array
*/
public static function limitations()
{
static $limitations;
if ($limitations === null) {
$db = eZDB::instance();
$dbName = md5($db->DB);
$cacheDir = eZSys::cacheDirectory();
$phpCache = new eZPHPCreator($cacheDir, 'statelimitations_' . $dbName . '.php', '', array('clustering' => 'statelimitations'));
$handler = eZExpiryHandler::instance();
$storedTimeStamp = $handler->hasTimestamp('state-limitations') ? $handler->timestamp('state-limitations') : false;
$expiryTime = $storedTimeStamp !== false ? $storedTimeStamp : 0;
if ($phpCache->canRestore($expiryTime)) {
$var = $phpCache->restore(array('state_limitations' => 'state_limitations'));
$limitations = $var['state_limitations'];
} else {
$limitations = array();
$groups = self::fetchByConditions(array("identifier NOT LIKE 'ez%'"), false, false);
foreach ($groups as $group) {
$name = 'StateGroup_' . $group->attribute('identifier');
$limitations[$name] = array('name' => $name, 'values' => array(), 'class' => __CLASS__, 'function' => 'limitationValues', 'parameter' => array($group->attribute('id')));
}
$phpCache->addVariable('state_limitations', $limitations);
$phpCache->store();
}
if ($storedTimeStamp === false) {
$handler->setTimestamp('state-limitations', time());
}
}
return $limitations;
}
示例11: expireCache
/**
* Expires the translation cache
*
* @param int $timestamp An optional timestamp cache should be exired from. Current timestamp used by default
* @param string $locale Optional translation's locale to expire specifically. Expires global ts cache by default.
*
* @return void
*/
public static function expireCache( $timestamp = false, $locale = null )
{
eZExpiryHandler::registerShutdownFunction();
if ( $timestamp === false )
$timestamp = time();
$handler = eZExpiryHandler::instance();
if ( $locale )
$handler->setTimestamp( self::EXPIRY_KEY . '-' . $locale, $timestamp );
else
$handler->setTimestamp( self::EXPIRY_KEY, $timestamp );
$handler->store();
self::resetGlobals();
}
示例12: shutdown
function shutdown($exitCode = false, $exitText = false)
{
$cli = eZCLI::instance();
if (class_exists('eZDB') and eZDB::hasInstance()) {
$db = eZDB::instance(false, array('show_errors' => false));
// Perform transaction check
$transactionCounterCheck = eZDB::checkTransactionCounter();
if (isset($transactionCounterCheck['error'])) {
$cli->error($transactionCounterCheck['error']);
}
if ($this->UseSession and $db->isConnected()) {
eZUser::logoutCurrent();
eZSession::remove();
}
}
$webOutput = $cli->isWebOutput();
if ($this->UseDebugOutput or eZDebug::isDebugEnabled()) {
if ($this->DebugMessage) {
fputs(STDERR, $this->DebugMessage);
}
fputs(STDERR, eZDebug::printReport(false, $webOutput, true, $this->AllowedDebugLevels, $this->UseDebugAccumulators, $this->UseDebugTimingPoints, $this->UseIncludeFiles));
}
eZExecution::cleanup();
eZExecution::setCleanExit();
eZExpiryHandler::shutdown();
$this->setIsInitialized(false);
if ($exitCode !== false) {
$this->ExitCode = $exitCode;
}
if ($this->ExitCode !== false) {
if ($exitText !== false) {
$cli->output($exitText);
}
exit($this->ExitCode);
}
}
示例13: cleanupCache
/**
* Expire user access / info cache globally
*/
static function cleanupCache()
{
$handler = eZExpiryHandler::instance();
$handler->setTimestamp('user-info-cache', time());
$handler->store();
}
示例14: processCached
function processCached($tpl, $functionChildren, $rootNamespace, $currentNamespace, $placementString, $keys, $subtreeExpiry, $expiry, $ignoreContentExpiry)
{
// Fetch the current siteaccess
$accessName = false;
if (isset($GLOBALS['eZCurrentAccess']['name'])) {
$accessName = $GLOBALS['eZCurrentAccess']['name'];
}
if ($keys === null) {
$keyArray = array($placementString, $accessName);
} else {
$keyArray = array($keys, $placementString, $accessName);
}
$nodeID = $subtreeExpiry ? eZTemplateCacheBlock::decodeNodeID($subtreeExpiry) : false;
$phpPath = eZTemplateCacheBlock::cachePath(eZTemplateCacheBlock::keyString($keyArray), $nodeID);
$ttl = $expiry > 0 ? $expiry : null;
if ($subtreeExpiry !== null) {
$ignoreContentExpiry = true;
} else {
if ($ignoreContentExpiry === null) {
$ignoreContentExpiry = false;
}
}
$globalExpiryTime = -1;
if ($ignoreContentExpiry == false) {
$globalExpiryTime = eZExpiryHandler::getTimestamp('template-block-cache', -1);
}
$globalExpiryTime = max(eZExpiryHandler::getTimestamp('global-template-block-cache', -1), $globalExpiryTime);
// Check if we can restore
$cacheFile = eZClusterFileHandler::instance($phpPath);
$args = array("tpl" => $tpl, "functionChildren" => $functionChildren, "rootNamespace" => $rootNamespace, "currentNamespace" => $currentNamespace);
return $cacheFile->processCache(array('eZTemplateCacheBlock', 'retrieveContent'), array($this, 'generateProcessedContent'), $ttl, $globalExpiryTime, $args);
}
示例15: registerShutdownFunction
/**
* Registers the shutdown function.
* @see eZExpiryHandler::shutdown()
*/
public static function registerShutdownFunction()
{
if (!eZExpiryHandler::$isShutdownFunctionRegistered) {
register_shutdown_function(array('eZExpiryHandler', 'shutdown'));
eZExpiryHandler::$isShutdownFunctionRegistered = true;
}
}