当前位置: 首页>>代码示例>>PHP>>正文


PHP SS_Cache类代码示例

本文整理汇总了PHP中SS_Cache的典型用法代码示例。如果您正苦于以下问题:PHP SS_Cache类的具体用法?PHP SS_Cache怎么用?PHP SS_Cache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SS_Cache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getVersion

 /**
  * Gets the current version of Code Bank
  * @return {string} Version Number Plus Build Date
  */
 protected final function getVersion()
 {
     if (CB_VERSION != '@@VERSION@@') {
         return CB_VERSION . ' ' . CB_BUILD_DATE;
     }
     // Tries to obtain version number from composer.lock if it exists
     $composerLockPath = BASE_PATH . '/composer.lock';
     if (file_exists($composerLockPath)) {
         $cache = SS_Cache::factory('CodeBank_Version');
         $cacheKey = filemtime($composerLockPath);
         $version = $cache->load($cacheKey);
         if ($version) {
             $version = $version;
         } else {
             $version = '';
         }
         if (!$version && ($jsonData = file_get_contents($composerLockPath))) {
             $lockData = json_decode($jsonData);
             if ($lockData && isset($lockData->packages)) {
                 foreach ($lockData->packages as $package) {
                     if ($package->name == 'undefinedoffset/silverstripe-codebank' && isset($package->version)) {
                         $version = $package->version;
                         break;
                     }
                 }
                 $cache->save($version, $cacheKey);
             }
         }
     }
     if (!empty($version)) {
         return $version;
     }
     return _t('CodeBank.DEVELOPMENT_BUILD', '_Development Build');
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:38,代码来源:CodeBankGridField_ItemRequest.php

示例2: __call

 public function __call($method, $arguments)
 {
     // do not make requests with an invalid key
     if ($method != 'ping' && !$this->isApiKeyValid()) {
         return;
     }
     if ($this->getAutoCache()) {
         $cache_key = $this->makeCacheKey($method, $arguments);
         $cache = SS_Cache::factory(__CLASS__);
         if ($result = $cache->load($cache_key)) {
             return unserialize($result);
         }
     }
     try {
         $result = call_user_func_array(array($this->client, $method), $arguments);
     } catch (Exception $e) {
         if (Director::isDev() && $this->debug_exceptions) {
             var_dump($e);
         }
         $result = false;
     }
     if ($this->getAutoCache()) {
         $cache->save(serialize($result));
     }
     return $result;
 }
开发者ID:helpfulrobot,项目名称:briceburg-silverstripe-mailchimp-flexiform,代码行数:26,代码来源:FlexiFormMailChimpClient.php

示例3: __construct

	/**
	 * Constructs and initialises a new configuration object, either loading
	 * from the cache or re-scanning for classes.
	 *
	 * @param string $base The project base path.
	 * @param bool   $forceRegen Force the manifest to be regenerated.
	 */
	public function __construct($base, $includeTests = false, $forceRegen = false ) {
		$this->base = $base;

		// Get the Zend Cache to load/store cache into
		$this->cache = SS_Cache::factory('SS_Configuration', 'Core', array(
			'automatic_serialization' => true,
			'lifetime' => null
		));

		// Unless we're forcing regen, try loading from cache
		if (!$forceRegen) {
			// The PHP config sources are always needed
			$this->phpConfigSources = $this->cache->load('php_config_sources');
			// Get the variant key spec
			$this->variantKeySpec = $this->cache->load('variant_key_spec');
			// Try getting the pre-filtered & merged config for this variant
			if (!($this->yamlConfig = $this->cache->load('yaml_config_'.$this->variantKey()))) {
				// Otherwise, if we do have the yaml config fragments (and we should since we have a variant key spec) work out the config for this variant
				if ($this->yamlConfigFragments = $this->cache->load('yaml_config_fragments')) {
					$this->buildYamlConfigVariant();
				}
			}
		}

		// If we don't have a config yet, we need to do a full regen to get it
		if (!$this->yamlConfig) {
			$this->regenerate($includeTests);
			$this->buildYamlConfigVariant();
		}
	}
开发者ID:redema,项目名称:sapphire,代码行数:37,代码来源:ConfigManifest.php

示例4: getCache

 /**
  * @return Zend_Cache_Frontend
  */
 public function getCache()
 {
     if (!$this->cache) {
         $this->cache = SS_Cache::factory('CurrencyConverter');
     }
     return $this->cache;
 }
开发者ID:helpfulrobot,项目名称:webtorque-currency-converter,代码行数:10,代码来源:CurrencyConverter.php

示例5: destroyJSONCahces

 private function destroyJSONCahces()
 {
     $cacheNames = [EventsController::EVENTS_CACHE_NAME, EventsController::CONFIG_CACHE_NAME];
     foreach ($cacheNames as $cacheName) {
         SS_Cache::factory($cacheName)->clean(Zend_Cache::CLEANING_MODE_ALL);
     }
 }
开发者ID:ehyland,项目名称:some-painter-cms,代码行数:7,代码来源:DestroyCache.php

示例6: setUp

 public function setUp()
 {
     parent::setUp();
     // clear cache
     SS_Cache::factory('local_cache')->clean(Zend_Cache::CLEANING_MODE_ALL);
     Member::add_extension('CacheableExtension');
 }
开发者ID:notthatbad,项目名称:silverstripe-caching,代码行数:7,代码来源:CachedDataListTest.php

示例7: run

 /**
  * 
  * @param SS_HTTPRequest $request
  */
 public function run($request)
 {
     $newLine = CacheableNavigation_Rebuild::new_line();
     SS_Cache::pick_backend(CACHEABLE_STORE_NAME, CACHEABLE_STORE_FOR, CACHEABLE_STORE_WEIGHT);
     SS_Cache::factory(CACHEABLE_STORE_FOR)->clean('all');
     echo 'Cleanup: ' . CACHEABLE_STORE_NAME . " done." . $newLine;
 }
开发者ID:deviateltd,项目名称:silverstripe-cacheable,代码行数:11,代码来源:CacheableNavigation_Clean.php

示例8: getCache

 /**
  *
  * @return Zend_Cache_Core
  */
 public function getCache()
 {
     if (!$this->cache) {
         $this->cache = SS_Cache::factory('restricted_perms', 'Output', array('automatic_serialization' => true, 'automatic_cleaning_factor' => 0));
     }
     return $this->cache;
 }
开发者ID:nyeholt,项目名称:silverstripe-restrictedobjects,代码行数:11,代码来源:PermissionService.php

示例9: setUp

 public function setUp()
 {
     parent::setUp();
     $this->defaultToken = Config::inst()->get('TokenAuth', 'DevToken');
     // clear cache
     SS_Cache::factory('rest_cache')->clean(Zend_Cache::CLEANING_MODE_ALL);
 }
开发者ID:EduardMa,项目名称:silverstripe-rest-api,代码行数:7,代码来源:RestTest.php

示例10: cache

 protected function cache()
 {
     if (!$this->cache) {
         $this->cache = \SS_Cache::factory('SocialFeed_Providers', 'Output', ['lifetime' => $this->cacheLifetime * 60 * 60]);
     }
     return $this->cache;
 }
开发者ID:spekulatius,项目名称:ss-social-feed,代码行数:7,代码来源:HTTP.php

示例11: getCache

 /**
  * @return Zend_Cache_Frontend
  */
 public static function getCache()
 {
     if (!self::$cache) {
         self::$cache = SS_Cache::factory('Geocoder');
     }
     return self::$cache;
 }
开发者ID:lekoala,项目名称:silverstripe-geotools,代码行数:10,代码来源:Geocoder.php

示例12: get_cache

 /**
  * @return SS_Cache
  */
 protected static function get_cache()
 {
     $lifetime = Config::inst()->get(__CLASS__, 'lifetime');
     $cache = SS_Cache::factory(__CLASS__);
     $cache->setLifetime($lifetime);
     return $cache;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-textextraction,代码行数:10,代码来源:FileTextCache.php

示例13: GetPardotTrackingJs

    /**
     *gets tracking code based on campaign
     *@return tracking javascript for pardot api
     */
    public static function GetPardotTrackingJs()
    {
        $html = false;
        $campaign = PardotConfig::getCampaignCode();
        if ($campaign) {
            $tracker_cache = SS_Cache::factory('Pardot');
            if (!($tracking_code_template = $tracker_cache->load('pardot_tracking_code_template'))) {
                $api_credentials = PardotConfig::getPardotCredentials();
                $pardot = new Pardot_API();
                if (!$pardot->is_authenticated()) {
                    $pardot->authenticate($api_credentials);
                }
                $account = $pardot->get_account();
                if (isset($account->tracking_code_template)) {
                    $tracking_code_template = $account->tracking_code_template;
                    $tracker_cache->save($tracking_code_template, 'pardot_tracking_code_template');
                }
            }
            $tracking_code_template = str_replace('%%CAMPAIGN_ID%%', $campaign + 1000, $tracking_code_template);
            $campaign = $campaign + 1000;
            $html = <<<HTML
<script> type="text/javascript">
piCId = '{$campaign}';
{$tracking_code_template}
</script>
HTML;
        }
        return $html;
    }
开发者ID:helpfulrobot,项目名称:bluehousegroup-silverstripe-pardot,代码行数:33,代码来源:PardotTracker.php

示例14: updateCMSFields

 /**
  * Updates the fields used in the CMS
  * @see DataExtension::updateCMSFields()     
  */
 public function updateCMSFields(FieldList $fields)
 {
     Requirements::CSS('blogcategories/css/cms-blog-categories.css');
     // Try to fetch categories from cache
     $categories = $this->getAllBlogCategories();
     if ($categories->count() >= 1) {
         $cacheKey = md5($categories->sort('LastEdited', 'DESC')->First()->LastEdited);
         $cache = SS_Cache::factory('BlogCategoriesList');
         if (!($categoryList = $cache->load($cacheKey))) {
             $categoryList = "<ul>";
             foreach ($categories->column('Title') as $title) {
                 $categoryList .= "<li>" . Convert::raw2xml($title) . "</li>";
             }
             $categoryList .= "</ul>";
             $cache->save($categoryList, $cacheKey);
         }
     } else {
         $categoryList = "<ul><li>No categories exist. Categories can be added from the BlogTree or the BlogHolder page.</li></ul>";
     }
     //categories tab
     $gridFieldConfig = GridFieldConfig_RelationEditor::create();
     $fields->addFieldToTab('Root.Categories', GridField::create('BlogCategories', 'Blog Categories', $this->owner->BlogCategories(), $gridFieldConfig));
     $fields->addFieldToTab('Root.Categories', ToggleCompositeField::create('ExistingCategories', 'View Existing Categories', array(new LiteralField("CategoryList", $categoryList)))->setHeadingLevel(4));
     // Optionally default category to current holder
     if (Config::inst()->get('BlogCategory', 'limit_to_holder')) {
         $holder = $this->owner->Parent();
         $gridFieldConfig->getComponentByType('GridFieldDetailForm')->setItemEditFormCallback(function ($form, $component) use($holder) {
             $form->Fields()->push(HiddenField::create('ParentID', false, $holder->ID));
         });
     }
 }
开发者ID:helpfulrobot,项目名称:ioti-silverstripe-blogcategories,代码行数:35,代码来源:BlogCategoryEntry.php

示例15: LatestTweetsList

 public function LatestTweetsList($limit = '5')
 {
     $conf = SiteConfig::current_site_config();
     if (empty($conf->TwitterName) || empty($conf->TwitterConsumerKey) || empty($conf->TwitterConsumerSecret) || empty($conf->TwitterAccessToken) || empty($conf->TwitterAccessTokenSecret)) {
         return new ArrayList();
     }
     $cache = SS_Cache::factory('LatestTweets_cache');
     if (!($results = unserialize($cache->load(__FUNCTION__)))) {
         $results = new ArrayList();
         require_once dirname(__FILE__) . '/tmhOAuth/tmhOAuth.php';
         require_once dirname(__FILE__) . '/tmhOAuth/tmhUtilities.php';
         $tmhOAuth = new tmhOAuth(array('consumer_key' => $conf->TwitterConsumerKey, 'consumer_secret' => $conf->TwitterConsumerSecret, 'user_token' => $conf->TwitterAccessToken, 'user_secret' => $conf->TwitterAccessTokenSecret, 'curl_ssl_verifypeer' => false));
         $code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => $conf->TwitterName, 'count' => $limit));
         $tweets = $tmhOAuth->response['response'];
         $json = new JSONDataFormatter();
         if (($arr = $json->convertStringToArray($tweets)) && is_array($arr) && isset($arr[0]['text'])) {
             foreach ($arr as $tweet) {
                 try {
                     $here = new DateTime(SS_Datetime::now()->getValue());
                     $there = new DateTime($tweet['created_at']);
                     $there->setTimezone($here->getTimezone());
                     $date = $there->Format('Y-m-d H:i:s');
                 } catch (Exception $e) {
                     $date = 0;
                 }
                 $results->push(new ArrayData(array('Text' => nl2br(tmhUtilities::entify_with_options($tweet, array('target' => '_blank'))), 'Date' => SS_Datetime::create_field('SS_Datetime', $date))));
             }
         }
         $cache->save(serialize($results), __FUNCTION__);
     }
     return $results;
 }
开发者ID:unisolutions,项目名称:silverstripe-latesttweets,代码行数:32,代码来源:LaTw_Page_Controller_Extension.php


注:本文中的SS_Cache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。