本文整理汇总了PHP中eZExpiryHandler::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP eZExpiryHandler::instance方法的具体用法?PHP eZExpiryHandler::instance怎么用?PHP eZExpiryHandler::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZExpiryHandler
的用法示例。
在下文中一共展示了eZExpiryHandler::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct( $location = null, array $options = array() )
{
eZExpiryHandler::registerShutdownFunction();
$this->expiryHandler = eZExpiryHandler::instance();
parent::__construct( $location, $options );
}
示例2: 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;
}
示例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: isComplexViewModeCacheExpired
/**
* Returns true if the viewmode is a complex viewmode and the viewmode timestamp is expired.
*
* @param string $viewMode
* @param int $timestamp UNIX Timestamp
* @return bool
*/
static function isComplexViewModeCacheExpired( $viewMode, $timestamp )
{
if ( !eZContentObject::isComplexViewMode( $viewMode ) )
return false;
$handler = eZExpiryHandler::instance();
if ( !$handler->hasTimestamp( 'content-complex-viewmode-cache' ) )
return false;
$expiryTime = $handler->timestamp( 'content-complex-viewmode-cache' );
if ( $expiryTime > $timestamp )
return true;
return false;
}
示例7: shutdown
/**
* Called at the end of execution and will store the data if it is modified.
*/
static function shutdown()
{
if (eZExpiryHandler::hasInstance()) {
eZExpiryHandler::instance()->store();
}
}
示例8: 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()");
}
示例9: cleanupCache
/**
* Expire user access / info cache globally
*/
static function cleanupCache()
{
$handler = eZExpiryHandler::instance();
$handler->setTimestamp('user-info-cache', time());
$handler->store();
}
示例10: 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];
}
示例11: 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;
}
示例12: 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();
}
示例13: isImageTimestampValid
function isImageTimestampValid($timestamp)
{
$expiryHandler = eZExpiryHandler::instance();
if ($expiryHandler->hasTimestamp('image-manager-alias')) {
$aliasTimestamp = $expiryHandler->timestamp('image-manager-alias');
return $timestamp > $aliasTimestamp;
}
return true;
}
示例14: __construct
public function __construct($location = null, array $options = array())
{
$this->expiryHandler = eZExpiryHandler::instance();
parent::__construct($location, $options);
}
示例15: 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();
}