本文整理汇总了PHP中eZExpiryHandler类的典型用法代码示例。如果您正苦于以下问题:PHP eZExpiryHandler类的具体用法?PHP eZExpiryHandler怎么用?PHP eZExpiryHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZExpiryHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:32,代码来源:ezuserdiscountrule.php
示例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 ) );
}
开发者ID:nottavi,项目名称:ezpublish,代码行数:29,代码来源:eztemplatecacheblock.php
示例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();
}
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:12,代码来源:clear_routes.php
示例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));
}
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:21,代码来源:ezphpcreator_regression.php
示例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'));
}
开发者ID:runelangseid,项目名称:ezpublish,代码行数:64,代码来源:ezpackage_regression.php
示例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'));
}
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:9,代码来源:ezcontentfunctioncollection.php
示例7: shutdown
/**
* Runs the shutdown process
*/
protected function shutdown($reInitialize = true)
{
eZExecution::cleanup();
eZExecution::setCleanExit();
eZExpiryHandler::shutdown();
if ($reInitialize) {
$this->isInitialized = false;
}
}
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:12,代码来源:ezpkernelrest.php
示例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;
}
开发者ID:nottavi,项目名称:ezpublish,代码行数:17,代码来源:ezurlwildcard.php
示例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();
}
开发者ID:nfrp,项目名称:ezpublish,代码行数:11,代码来源:ezcache.php
示例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;
}
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:35,代码来源:ezcontentobjectstategroup.php
示例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();
}
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:23,代码来源:eztstranslator.php
示例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);
}
}
开发者ID:ezsystems,项目名称:ezpublish-legacy,代码行数:36,代码来源:ezscript.php
示例13: cleanupCache
/**
* Expire user access / info cache globally
*/
static function cleanupCache()
{
$handler = eZExpiryHandler::instance();
$handler->setTimestamp('user-info-cache', time());
$handler->store();
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:9,代码来源:ezuser.php
示例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);
}
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:32,代码来源:eztemplatecachefunction.php
示例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;
}
}
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:11,代码来源:ezexpiryhandler.php
示例16: testExpireCache
/**
* Test for expireCache
*
* Outline:
* 1. Manually set the cache expiry timestamp to a date in the past
* 2. Check that it is not expired
* 3. Call expireCache
* 4. Check that the cache is expired
*/
public function testExpireCache()
{
$this->markTestSkipped("Needs to be rewritten due to the refactoring");
$expiryHandler = eZExpiryHandler::instance();
// 1. Manually set the cache expiry timestamp to a date in the past
$expiryHandler->setTimestamp(eZURLWildcard::CACHE_SIGNATURE, time() - 3600);
// 2. Check that it is not expired
$this->assertFalse(eZURLWildcard::isCacheExpired(time() - 1), "Expiry timestamp is in the past, cache should not be expired");
// 3. Call expireCache
eZURLWildcard::expireCache();
// 4. Check that the cache is expired
$this->assertTrue(eZURLWildcard::isCacheExpired(time() - 1), "Cache should have been expired by expireCache()");
}
开发者ID:nlescure,项目名称:ezpublish,代码行数:22,代码来源:ezurlwildcard_test.php
示例17: expireCache
/**
* Clears all content class attribute related caches
*
* @param int $contentClassAttributeID Specific attribute ID to clear cache for
* @param int $contentClassID Specific attribute ID to clear cache for
*
* @return void
* @since 4.2
*/
public static function expireCache( $contentClassAttributeID = false, $contentClassID = false)
{
unset( $GLOBALS['eZContentClassAttributeCacheListFull'] );
if ( $contentClassID !== false )
{
if ( isset( $GLOBALS['eZContentClassAttributeCacheList'][$contentClassID] ) )
{
unset( $GLOBALS['eZContentClassAttributeCacheList'][$contentClassID] );
}
}
else
{
unset( $GLOBALS['eZContentClassAttributeCacheList'] );
}
if ( $contentClassAttributeID !== false )
{
if ( isset( $GLOBALS['eZContentClassAttributeCache'][$contentClassAttributeID] ) )
{
unset( $GLOBALS['eZContentClassAttributeCache'][$contentClassAttributeID] );
}
}
else
{
unset( $GLOBALS['eZContentClassAttributeCache'] );
}
// expire cache file by timestamp
$handler = eZExpiryHandler::instance();
$handler->setTimestamp( 'class-identifier-cache', time() + 1 );
$handler->store();
// expire local, in-memory cache
self::$identifierHash = null;
}
开发者ID:nottavi,项目名称:ezpublish,代码行数:43,代码来源:ezcontentclassattribute.php
示例18: expireCache
/**
* Expires the translation cache
*
* @param int $timestamp An optional timestamp cache should be exired from. Current timestamp used by default
*
* @return void
*/
public static function expireCache($timestamp = false)
{
eZExpiryHandler::registerShutdownFunction();
if ($timestamp === false) {
$timestamp = time();
}
$handler = eZExpiryHandler::instance();
$handler->setTimestamp(self::EXPIRY_KEY, $timestamp);
$handler->store();
self::$expiryTimestamp = $timestamp;
}
开发者ID:runelangseid,项目名称:ezpublish,代码行数:18,代码来源:eztstranslator.php
示例19: revertFromTemporaryVersion
function revertFromTemporaryVersion()
{
$temporaryVersion = eZRole::fetch(0, $this->attribute('id'));
if ($temporaryVersion === null) {
return 0;
}
$this->removePolicies();
$this->setAttribute('name', $temporaryVersion->attribute('name'));
$this->setAttribute('is_new', 0);
$db = eZDB::instance();
$db->begin();
$this->store();
$query = "UPDATE ezpolicy\n SET role_id = " . $this->attribute('id') . "\n WHERE role_id = " . $temporaryVersion->attribute('id');
$db->query($query);
$temporaryVersion->removePolicies(false);
$temporaryVersion->remove();
$db->commit();
// Expire role cache
eZExpiryHandler::registerShutdownFunction();
$handler = eZExpiryHandler::instance();
$handler->setTimestamp('user-info-cache', time());
$handler->setTimestamp('user-class-cache', time());
$handler->store();
}
开发者ID:,项目名称:,代码行数:24,代码来源:
示例20: activeExtensions
/**
* Return an array with activated extensions.
*
* @note Default extensions are those who are loaded before a siteaccess are determined while access extensions
* are loaded after siteaccess is set.
*
* @param false|string $extensionType Decides which extension to include in the list, the follow values are possible:
* - false - Means add both default and access extensions
* - 'default' - Add only default extensions
* - 'access' - Add only access extensions
* @param eZINI|null $siteINI Optional parameter to be able to only do change on specific instance of site.ini
* @return array
*/
public static function activeExtensions( $extensionType = false, eZINI $siteINI = null )
{
if ( $siteINI === null )
{
$siteINI = eZINI::instance();
}
$activeExtensions = array();
if ( !$extensionType || $extensionType === 'default' )
{
$activeExtensions = $siteINI->variable( 'ExtensionSettings', 'ActiveExtensions' );
}
if ( !$extensionType || $extensionType === 'access' )
{
$activeExtensions = array_merge( $activeExtensions,
$siteINI->variable( 'ExtensionSettings', 'ActiveAccessExtensions' ) );
}
if ( isset( $GLOBALS['eZActiveExtensions'] ) )
{
$activeExtensions = array_merge( $activeExtensions,
$GLOBALS['eZActiveExtensions'] );
}
// return empty array as is to avoid further unneeded overhead
if ( !isset( $activeExtensions[0] ) )
{
return $activeExtensions;
}
// return array as is if ordering is disabled to avoid cache overhead
$activeExtensions = array_unique( $activeExtensions );
if ( $siteINI->variable( 'ExtensionSettings', 'ExtensionOrdering' ) !== 'enabled' )
{
// @todo Introduce a debug setting or re use existing dev mods to check that all extensions exists
return $activeExtensions;
}
$cacheIdentifier = md5( serialize( $activeExtensions ) );
if ( isset ( self::$activeExtensionsCache[$cacheIdentifier] ) )
{
return self::$activeExtensionsCache[$cacheIdentifier];
}
// cache has to be stored by siteaccess + $extensionType
$extensionDirectory = self::baseDirectory();
$expiryHandler = eZExpiryHandler::instance();
$phpCache = new eZPHPCreator( self::CACHE_DIR, "active_extensions_{$cacheIdentifier}.php" );
$expiryTime = $expiryHandler->hasTimestamp( 'active-extensions-cache' ) ? $expiryHandler->timestamp( 'active-extensions-cache' ) : 0;
if ( !$phpCache->canRestore( $expiryTime ) )
{
self::$activeExtensionsCache[$cacheIdentifier] = self::extensionOrdering( $activeExtensions );
// Check that all extensions defined actually exists before storing cache
foreach ( self::$activeExtensionsCache[$cacheIdentifier] as $activeExtension )
{
if ( !file_exists( $extensionDirectory . '/' . $activeExtension ) )
{
eZDebug::writeError( "Extension '$activeExtension' does not exist, looked for directory '" . $extensionDirectory . '/' . $activeExtension . "'", __METHOD__ );
}
}
$phpCache->addVariable( 'activeExtensions', self::$activeExtensionsCache[$cacheIdentifier] );
$phpCache->store();
}
else
{
$data = $phpCache->restore( array( 'activeExtensions' => 'activeExtensions' ) );
self::$activeExtensionsCache[$cacheIdentifier] = $data['activeExtensions'];
}
return self::$activeExtensionsCache[$cacheIdentifier];
}
开发者ID:nottavi,项目名称:ezpublish,代码行数:88,代码来源:ezextension.php
注:本文中的eZExpiryHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论