本文整理汇总了PHP中SS_Cache::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_Cache::factory方法的具体用法?PHP SS_Cache::factory怎么用?PHP SS_Cache::factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_Cache
的用法示例。
在下文中一共展示了SS_Cache::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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();
}
}
示例2: getCache
/**
* @return Zend_Cache_Frontend
*/
public function getCache()
{
if (!$this->cache) {
$this->cache = SS_Cache::factory('CurrencyConverter');
}
return $this->cache;
}
示例3: 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);
}
}
示例4: setUp
public function setUp()
{
parent::setUp();
// clear cache
SS_Cache::factory('local_cache')->clean(Zend_Cache::CLEANING_MODE_ALL);
Member::add_extension('CacheableExtension');
}
示例5: cache
protected function cache()
{
if (!$this->cache) {
$this->cache = Cache::factory('Milkyway_SS_InfoBoxes_Wunderlist_Provider', 'Output', ['lifetime' => $this->cacheLifetime * 60 * 60]);
}
return $this->cache;
}
示例6: __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
示例7: getEventsAction
public function getEventsAction(SS_HTTPRequest $request)
{
// Search date
$date = DBField::create_field("SS_Datetime", $request->param("SearchDate"));
if (!$date->getValue()) {
$date = SS_Datetime::now();
}
// Get event data
$cache = SS_Cache::factory(self::EVENTS_CACHE_NAME);
$cacheKey = $date->Format('Y_m_d');
if ($result = $cache->load($cacheKey)) {
$data = unserialize($result);
} else {
$data = EventsDataUtil::get_events_data_for_day($date);
$cache->save(serialize($data), $cacheKey);
}
// Get init data
if ($request->param("GetAppConfig")) {
$cache = SS_Cache::factory(self::CONFIG_CACHE_NAME);
$cacheKey = 'APP_CONFIG';
if ($result = $cache->load($cacheKey)) {
$configData = unserialize($result);
} else {
$configData = AppConfigDataUtil::get_config_data();
$cache->save(serialize($configData), $cacheKey);
}
$data['appConfig'] = $configData;
}
return $this->sendResponse($data);
}
示例8: 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;
}
示例9: 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;
}
示例10: cache
protected function cache()
{
if (!$this->cache) {
$this->cache = \SS_Cache::factory('SocialFeed_Providers', 'Output', ['lifetime' => $this->cacheLifetime * 60 * 60]);
}
return $this->cache;
}
示例11: getCache
/**
* @return Zend_Cache_Frontend
*/
public static function getCache()
{
if (!self::$cache) {
self::$cache = SS_Cache::factory('Socialstream');
}
return self::$cache;
}
示例12: 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
示例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;
}
示例14: 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);
}
示例15: 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));
});
}
}