本文整理汇总了PHP中GeneralCache::cacheEntry方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralCache::cacheEntry方法的具体用法?PHP GeneralCache::cacheEntry怎么用?PHP GeneralCache::cacheEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralCache
的用法示例。
在下文中一共展示了GeneralCache::cacheEntry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setAsProcessed
public static function setAsProcessed($tableName, $identifier)
{
$processedTables = static::resolveProcessedTableNames($identifier);
if (!in_array($tableName, $processedTables)) {
$processedTables[] = $tableName;
GeneralCache::cacheEntry($identifier, $processedTables);
}
}
示例2: cacheEntry
public static function cacheEntry($identifier, $entry)
{
assert('is_string($entry) || is_numeric($entry)');
parent::cacheEntry($identifier, $entry);
if (static::supportsAndAllowsDatabaseCaching()) {
ZurmoRedBean::exec("insert into actual_rights_cache\n (identifier, entry) values ('" . $identifier . "', '" . $entry . "') on duplicate key\n update entry = " . $entry);
}
}
示例3: save
/**
* Any changes to the model must be re-cached.
* @see RedBeanModel::save()
*/
public function save($runValidation = true, array $attributeNames = null)
{
$saved = parent::save($runValidation, $attributeNames);
if ($saved) {
GeneralCache::cacheEntry('CustomFieldData' . $this->name, $this);
}
return $saved;
}
示例4: testCanSetNullValueToCache
public function testCanSetNullValueToCache()
{
//if memcache is off this test will fail because memcache will not cache null values.
if (MEMCACHE_ON) {
GeneralCache::cacheEntry('somethingForTesting', null);
$value = GeneralCache::getEntry('somethingForTesting');
$this->assertNull($value);
}
}
示例5: getReadSubscriptionModelClassNames
/**
* Get all read subscription model class names
* @return array|mixed
*/
public static function getReadSubscriptionModelClassNames()
{
try {
return GeneralCache::getEntry('readPermissionsSubscriptionModelClassNames');
} catch (NotFoundException $e) {
$readPermissionsSubscriptionModelClassNames = self::findReadSubscriptionModelClassNames();
GeneralCache::cacheEntry('readPermissionsSubscriptionModelClassNames', $readPermissionsSubscriptionModelClassNames);
return $readPermissionsSubscriptionModelClassNames;
}
}
示例6: resolveByCacheAndGetVisibleAndOrderedAdminTabMenuByUser
/**
* @param $user
* @return array|mixed
*/
public static function resolveByCacheAndGetVisibleAndOrderedAdminTabMenuByUser($user)
{
assert('$user instanceof User && $user != null');
try {
$items = GeneralCache::getEntry(self::getAdminMenuViewItemsCacheIdentifier());
} catch (NotFoundException $e) {
$items = self::getVisibleAndOrderedAdminTabMenuByUser($user);
GeneralCache::cacheEntry(self::getAdminMenuViewItemsCacheIdentifier(), $items);
}
return $items;
}
示例7: getGlobalSearchScopingModuleNamesAndLabelsDataByUser
/**
* Given a user, return an array of module names and their translated labels, for which the user
* has the right to access and only modules that support the global search.
* @param User $user
* @return array of module names and labels.
*/
public static function getGlobalSearchScopingModuleNamesAndLabelsDataByUser(User $user)
{
assert('$user->id > 0');
try {
return GeneralCache::getEntry(self::getGlobalSearchScopingCacheIdentifier($user));
} catch (NotFoundException $e) {
$moduleNamesAndLabels = self::findGlobalSearchScopingModuleNamesAndLabelsDataByUser($user);
GeneralCache::cacheEntry(self::getGlobalSearchScopingCacheIdentifier($user), $moduleNamesAndLabels);
return $moduleNamesAndLabels;
}
}
示例8: loadMessages
/**
* Override of the parent method because of problems with Yii's default cache
* @see CDbMessageSource::loadMessages()
* @param string $category
* @param string $languageCode
* @return array $messages
*/
protected function loadMessages($category, $languageCode)
{
assert('is_string($category)');
assert('is_string($languageCode)');
try {
$messages = GeneralCache::getEntry(self::getMessageSourceCacheIdentifier($category, $languageCode));
} catch (NotFoundException $e) {
$messages = $this->loadMessagesFromDb($category, $languageCode);
GeneralCache::cacheEntry(self::getMessageSourceCacheIdentifier($category, $languageCode), $messages);
}
return $messages;
}
示例9: handleImports
/**
* Import all files that need to be included(for lazy loading)
* @param $event
*/
public function handleImports($event)
{
try {
$filesToInclude = GeneralCache::getEntry('filesToIncludeForTests');
} catch (NotFoundException $e) {
$filesToInclude = FileUtil::getFilesFromDir(Yii::app()->basePath . '/modules', Yii::app()->basePath . '/modules', 'application.modules', true);
$filesToIncludeFromFramework = FileUtil::getFilesFromDir(Yii::app()->basePath . '/core', Yii::app()->basePath . '/core', 'application.core', true);
$totalFilesToIncludeFromModules = count($filesToInclude);
foreach ($filesToIncludeFromFramework as $key => $file) {
$filesToInclude[$totalFilesToIncludeFromModules + $key] = $file;
}
GeneralCache::cacheEntry('filesToIncludeForTests', $filesToInclude);
}
foreach ($filesToInclude as $file) {
Yii::import($file);
}
}
示例10: getMungableModelClassNames
public static function getMungableModelClassNames()
{
try {
return GeneralCache::getEntry('mungableModelClassNames');
} catch (NotFoundException $e) {
$mungableClassNames = self::findMungableModelClassNames();
GeneralCache::cacheEntry('mungableModelClassNames', $mungableClassNames);
return $mungableClassNames;
}
}
示例11: getMetadata
/**
* Returns metadata for the module.
* @see getDefaultMetadata()
* @param $user The current user.
* @returns An array of metadata.
*/
public static function getMetadata(User $user = null)
{
$className = get_called_class();
if ($user == null) {
try {
// not using default value to save cpu cycles on requests that follow the first exception.
return GeneralCache::getEntry($className . 'Metadata');
} catch (NotFoundException $e) {
}
}
$metadata = MetadataUtil::getMetadata($className, $user);
if (YII_DEBUG) {
$className::assertMetadataIsValid($metadata);
}
if ($user == null) {
GeneralCache::cacheEntry($className . 'Metadata', $metadata);
}
return $metadata;
}
示例12: setMetadata
/**
* @param array $metadata
*/
public static function setMetadata(array $metadata)
{
$className = get_called_class();
if (YII_DEBUG) {
$className::assertMetadataIsValid($metadata);
}
MetadataUtil::setMetadata($className, $metadata);
GeneralCache::cacheEntry($className . 'Metadata', $metadata);
}
示例13: testForgetAllNotDeleteOtherDataFromCache
public function testForgetAllNotDeleteOtherDataFromCache()
{
if (MEMCACHE_ON && !PHP_CACHING_ON) {
GeneralCache::cacheEntry('somethingForTesting4', 34);
$value = GeneralCache::getEntry('somethingForTesting4');
$this->assertEquals(34, $value);
$originalAdditionalStringForCachePrefix = GeneralCache::getAdditionalStringForCachePrefix();
GeneralCache::setAdditionalStringForCachePrefix('ATEST');
GeneralCache::cacheEntry('somethingForTesting4', 43);
$value = GeneralCache::getEntry('somethingForTesting4');
$this->assertEquals(43, $value);
GeneralCache::forgetAll();
try {
GeneralCache::getEntry('somethingForTesting4');
$this->fail('NotFoundException exception is not thrown.');
} catch (NotFoundException $e) {
$this->assertTrue(true);
}
GeneralCache::setAdditionalStringForCachePrefix($originalAdditionalStringForCachePrefix);
$value = GeneralCache::getEntry('somethingForTesting4');
$this->assertEquals(34, $value);
}
}
示例14: registerUniqueIndexByMemberName
protected static function registerUniqueIndexByMemberName($member, $modelClassName)
{
$indexName = RedBeanModelMemberIndexMetadataAdapter::resolveRandomIndexName($member, true);
$uniqueIndexes = GeneralCache::getEntry(static::CACHE_KEY, array());
$uniqueIndexes[$modelClassName][$indexName] = array('members' => array($member), 'unique' => true);
GeneralCache::cacheEntry(static::CACHE_KEY, $uniqueIndexes);
}
示例15: setCacheIncrementValue
/**
* @param string $cacheType
* @param mixed $value
*/
protected static function setCacheIncrementValue($cacheType, $value)
{
GeneralCache::cacheEntry(static::$cacheIncrementValueVariableName . $cacheType, $value);
}