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


PHP Cache::createCache方法代码示例

本文整理汇总了PHP中Cache::createCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::createCache方法的具体用法?PHP Cache::createCache怎么用?PHP Cache::createCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cache的用法示例。


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

示例1: invalidateGadgetCache

 public static function invalidateGadgetCache(GadgetContext $context)
 {
     $request = new RemoteContentRequest($context->getUrl());
     $cache = Cache::createCache(Shindig_Config::get('data_cache'), 'RemoteContent');
     $cacheData = $cache->get($request->toHash());
     if ($cacheData) {
         $uris = array();
         $xml = $cacheData->getResponseContent();
         $parserClass = Shindig_Config::get('gadget_spec_parser');
         $parser = new $parserClass();
         $gadgetSpec = $parser->parse($xml, $context);
         if ($gadgetSpec->locales) {
             foreach ($gadgetSpec->locales as $locale) {
                 if (!empty($locale['messages'])) {
                     $uris[] = RemoteContentRequest::transformRelativeUrl($locale['messages'], $context->getUrl());
                 }
             }
         }
         if (is_array($gadgetSpec->preloads)) {
             foreach ($gadgetSpec->preloads as $preload) {
                 if (!empty($preload['href'])) {
                     $uris[] = RemoteContentRequest::transformRelativeUrl($preload['href'], $context->getUrl());
                 }
             }
         }
         if (is_array($gadgetSpec->templatesRequireLibraries)) {
             foreach ($gadgetSpec->templatesRequireLibraries as $libraryUrl) {
                 $uris[] = RemoteContentRequest::transformRelativeUrl($locale['messages'], $context->getUrl());
             }
         }
         $uris[] = $request->getUrl();
         self::invalidateRemoteContents($uris);
     }
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:34,代码来源:opOpenSocialToolKit.class.php

示例2: getJsUrl

 /**
  * generates the library string (core:caja:etc.js) including a checksum of all the
  * javascript content (?v=<md5 of js>) for cache busting
  *
  * @param array $features
  * @param Gadget $gadget
  * @return string the list of libraries in core:caja:etc.js?v=checksum> format
  */
 protected function getJsUrl($features)
 {
     if (!is_array($features) || !count($features)) {
         return 'null';
     }
     $registry = $this->context->getRegistry();
     // Given the JsServlet automatically expends the js library, we just need
     // to include the "leaf" nodes of the features.
     $ret = $features;
     foreach ($features as $feature) {
         $depFeatures = $registry->features[$feature]['deps'];
         $ret = array_diff($ret, $depFeatures);
     }
     $ret = implode(':', $ret);
     $cache = Cache::createCache(Config::get('feature_cache'), 'FeatureCache');
     if (($md5 = $cache->get(md5('getJsUrlMD5'))) === false) {
         $features = $registry->features;
         // Build a version string from the md5() checksum of all included javascript
         // to ensure the client always has the right version
         $inlineJs = '';
         foreach ($features as $feature => $content) {
             $inlineJs .= $registry->getFeatureContent($feature, $this->context, true);
         }
         $md5 = md5($inlineJs);
         $cache->set(md5('getJsUrlMD5'), $md5);
     }
     $ret .= ".js?v=" . $md5;
     return $ret;
 }
开发者ID:ndkhoiits,项目名称:gatein-shindig,代码行数:37,代码来源:GadgetRenderer.php

示例3: __construct

 /**
  * @param RemoteContentFetcher $basicFetcher
  * @param SigningFetcherFactory $signingFetcherFactory
  * @param SecurityTokenDecoder $signer
  */
 public function __construct(RemoteContentFetcher $basicFetcher = null, $signingFetcherFactory = null, $signer = null)
 {
     $this->basicFetcher = $basicFetcher ? $basicFetcher : new BasicRemoteContentFetcher();
     $this->signingFetcherFactory = $signingFetcherFactory;
     $this->signer = $signer;
     $this->cache = Cache::createCache(Shindig_Config::get('data_cache'), 'RemoteContent');
     $this->invalidateService = new DefaultInvalidateService($this->cache);
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:13,代码来源:BasicRemoteContent.php

示例4: __construct

 public function __construct()
 {
     try {
         $service = trim(Shindig_Config::get('invalidate_service'));
         if (!empty($service)) {
             $cache = Cache::createCache(Shindig_Config::get('data_cache'), 'RemoteContent');
             $this->service = new $service($cache);
         }
     } catch (ConfigException $e) {
         // Do nothing. If invalidate service is not specified in the config file.
         // All the requests to the handler will throw not implemented exception.
     }
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:13,代码来源:InvalidateHandler.php

示例5: __construct

 public function __construct(Cache $cache)
 {
     $this->cache = $cache;
     $this->invalidationEntry = Cache::createCache(Shindig_Config::get('data_cache'), 'InvalidationEntry');
     if (self::$makerCache == null) {
         self::$makerCache = Cache::createCache(Shindig_Config::get('data_cache'), 'MarkerCache');
         $value = self::$makerCache->expiredGet('marker');
         if ($value['found']) {
             self::$marker = $value['data'];
         } else {
             self::$marker = 0;
             self::$makerCache->set('marker', self::$marker);
         }
     }
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:15,代码来源:DefaultInvalidateService.php

示例6: getFeatureContent

 public function getFeatureContent($feature, GadgetContext $context, $isGadgetContext)
 {
     if (empty($feature)) {
         return '';
     }
     if (!isset($this->features[$feature])) {
         throw new GadgetException("Invalid feature: " . htmlentities($feature));
     }
     $featureName = $feature;
     $feature = $this->features[$feature];
     $filesContext = $isGadgetContext ? 'gadgetJs' : 'containerJs';
     if (!isset($feature[$filesContext])) {
         // no javascript specified for this context
         return '';
     }
     $ret = '';
     if (Config::get('compress_javascript')) {
         $featureCache = Cache::createCache(Config::get('feature_cache'), 'FeatureCache');
         if ($featureContent = $featureCache->get(md5('features:' . $featureName . $isGadgetContext))) {
             return $featureContent;
         }
     }
     foreach ($feature[$filesContext] as $entry) {
         switch ($entry['type']) {
             case 'URL':
                 $request = new RemoteContentRequest($entry['content']);
                 $request->getOptions()->ignoreCache = $context->getIgnoreCache();
                 $response = $context->getHttpFetcher()->fetch($request);
                 if ($response->getHttpCode() == '200') {
                     $ret .= $response->getResponseContent() . "\n";
                 }
                 break;
             case 'FILE':
                 $file = $feature['basePath'] . '/' . $entry['content'];
                 $ret .= file_get_contents($file) . "\n";
                 break;
             case 'INLINE':
                 $ret .= $entry['content'] . "\n";
                 break;
         }
     }
     if (Config::get('compress_javascript')) {
         $ret = JsMin::minify($ret);
         $featureCache->set(md5('features:' . $featureName . $isGadgetContext), $ret);
     }
     return $ret;
 }
开发者ID:ndkhoiits,项目名称:gatein-shindig,代码行数:47,代码来源:GadgetFeatureRegistry.php

示例7: setUp

 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     if (!extension_loaded('memcache')) {
         $message = 'memcache requires the memcache extention';
         throw new PHPUnit_Framework_SkippedTestSuiteError($message);
     }
     parent::setUp();
     $this->time = new MockRequestTime();
     try {
         $this->cache = Cache::createCache('CacheStorageMemcache', 'TestCache', $this->time);
     } catch (Exception $e) {
         $message = 'memcache server can not connect';
         throw new PHPUnit_Framework_SkippedTestSuiteError($message);
     }
     if (!is_resource($this->cache)) {
         $message = 'memcache server can not connect';
         throw new PHPUnit_Framework_SkippedTestSuiteError($message);
     }
 }
开发者ID:emma5021,项目名称:toba,代码行数:22,代码来源:CacheMemcacheTest.php

示例8: getJsUrl

 /**
  * generates the library string (core:caja:etc.js) including a checksum of all the
  * javascript content (?v=<md5 of js>) for cache busting
  *
  * @param string $libs
  * @param Gadget $gadget
  * @return string the list of libraries in core:caja:etc.js?v=checksum> format
  */
 protected function getJsUrl($features)
 {
     if (!is_array($features) || !count($features)) {
         return 'null';
     }
     $ret = implode(':', $features);
     $cache = Cache::createCache(Config::get('feature_cache'), 'FeatureCache');
     if (($md5 = $cache->get(md5('getJsUrlMD5'))) === false) {
         $registry = $this->context->getRegistry();
         $features = $registry->features;
         // Build a version string from the md5() checksum of all included javascript
         // to ensure the client always has the right version
         $inlineJs = '';
         foreach ($features as $feature => $content) {
             $inlineJs .= $registry->getFeatureContent($feature, $this->context, true);
         }
         $md5 = md5($inlineJs);
         $cache->set(md5('getJsUrlMD5'), $md5);
     }
     $ret .= ".js?v=" . $md5;
     return $ret;
 }
开发者ID:kevinj,项目名称:apache-incubator-shindig,代码行数:30,代码来源:GadgetRenderer.php

示例9: storeConsumerInfo

 private function storeConsumerInfo($gadgetUri, $serviceName, $consumerInfo)
 {
     if (!isset($consumerInfo[$this->CONSUMER_SECRET_KEY]) || !isset($consumerInfo[$this->CONSUMER_KEY_KEY]) || !isset($consumerInfo[$this->KEY_TYPE_KEY])) {
         throw new Exception("Invalid configuration in oauth.json");
     }
     $consumerSecret = $consumerInfo[$this->CONSUMER_SECRET_KEY];
     $consumerKey = $consumerInfo[$this->CONSUMER_KEY_KEY];
     $keyTypeStr = $consumerInfo[$this->KEY_TYPE_KEY];
     $keyType = 'HMAC_SYMMETRIC';
     if ($keyTypeStr == "RSA_PRIVATE") {
         $keyType = 'RSA_PRIVATE';
         $cache = Cache::createCache(Shindig_Config::get('data_cache'), 'OAuthToken');
         if (($cachedRequest = $cache->get(md5("RSA_KEY_" . $serviceName))) !== false) {
             $consumerSecret = $cachedRequest;
         } else {
             $key = $consumerInfo[$this->CONSUMER_SECRET_KEY];
             if (empty($key)) {
                 throw new Exception("Invalid key");
             }
             if (strpos($key, "-----BEGIN") === false) {
                 $strip_this = array(" ", "\n", "\r");
                 //removes breaklines and trim.
                 $rsa_private_key = trim(str_replace($strip_this, "", $key));
                 $consumerSecret = OAuth::$BEGIN_PRIVATE_KEY . "\n";
                 $chunks = str_split($rsa_private_key, 64);
                 foreach ($chunks as $chunk) {
                     $consumerSecret .= $chunk . "\n";
                 }
                 $consumerSecret .= OAuth::$END_PRIVATE_KEY;
             } else {
                 $consumerSecret = $key;
             }
             $cache->set(md5("RSA_KEY_" . $serviceName), $consumerSecret);
         }
     }
     $kas = new ConsumerKeyAndSecret($consumerKey, $consumerSecret, $keyType);
     $this->storeConsumerKeyAndSecret($gadgetUri, $serviceName, $kas);
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:38,代码来源:BasicGadgetOAuthTokenStore.php

示例10: setUp

 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->cache = Cache::createCache('CacheStorageFile', 'TestCache');
     $this->service = new DefaultInvalidateService($this->cache);
 }
开发者ID:emma5021,项目名称:toba,代码行数:9,代码来源:DefaultInvalidateServiceTest.php

示例11: instanceRegistry

 private function instanceRegistry()
 {
     // feature parsing is very resource intensive so by caching the result this saves upto 30% of the processing time
     $featureCache = Cache::createCache(Shindig_Config::get('feature_cache'), 'FeatureCache');
     if (!($registry = $featureCache->get(md5(Shindig_Config::get('features_path'))))) {
         $registry = new GadgetFeatureRegistry(Shindig_Config::get('features_path'));
         $featureCache->set(md5(Shindig_Config::get('features_path')), $registry);
     }
     return $registry;
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:10,代码来源:GadgetContext.php

示例12: die

        die("Shindig requires the {$module} extention, see <a href='http://www.php.net/{$module}'>http://www.php.net/{$module}</a> for more info");
    }
}
// Basic library requirements that are always needed
require PartuzaConfig::get('library_root') . "/Image.php";
require PartuzaConfig::get('library_root') . "/Language.php";
require PartuzaConfig::get('library_root') . "/Database.php";
require PartuzaConfig::get('library_root') . "/Dispatcher.php";
require PartuzaConfig::get('library_root') . "/Controller.php";
require PartuzaConfig::get('library_root') . "/Model.php";
require PartuzaConfig::get('library_root') . "/Cache.php";
require PartuzaConfig::get('library_root') . "/CacheStorage.php";
require PartuzaConfig::get('library_root') . "/CacheStorageApc.php";
require PartuzaConfig::get('library_root') . "/CacheStorageFile.php";
require PartuzaConfig::get('library_root') . "/CacheStorageMemcache.php";
require PartuzaConfig::get('controllers_root') . "/base/base.php";
// Files copied from shindig, required to make the security token
require PartuzaConfig::get('library_root') . "/Crypto.php";
require PartuzaConfig::get('library_root') . "/BlobCrypter.php";
require PartuzaConfig::get('library_root') . "/SecurityToken.php";
require PartuzaConfig::get('library_root') . "/BasicBlobCrypter.php";
require PartuzaConfig::get('library_root') . "/BasicSecurityToken.php";
// Initialize envirioment, and start the dispatcher
Language::set(PartuzaConfig::get('language'));
$db = new DB(PartuzaConfig::get('db_host'), PartuzaConfig::get('db_port'), PartuzaConfig::get('db_user'), PartuzaConfig::get('db_passwd'), PartuzaConfig::get('db_database'), false);
$uri = $_SERVER["REQUEST_URI"];
$cache = Cache::createCache(PartuzaConfig::get('data_cache'), 'Partuza');
if (($pos = strpos($_SERVER["REQUEST_URI"], '?')) !== false) {
    $uri = substr($_SERVER["REQUEST_URI"], 0, $pos);
}
new Dispatcher($uri);
开发者ID:unpush,项目名称:partuza,代码行数:31,代码来源:index.php

示例13: instanceRegistry

 protected function instanceRegistry()
 {
     // feature parsing is very resource intensive so by caching the result this saves upto 30% of the processing time
     $featureCache = Cache::createCache(Config::get('feature_cache'), 'FeatureCache');
     $key = md5(implode(',', Config::get('features_path')));
     if (!($registry = $featureCache->get($key))) {
         $registry = new GadgetFeatureRegistry(Config::get('features_path'));
         $featureCache->set($key, $registry);
     }
     return $registry;
 }
开发者ID:vuxuandung,项目名称:Partuza-bundle,代码行数:11,代码来源:GadgetContext.php

示例14: testCreateCache

 /**
  * Tests Cache::createCache()
  */
 public function testCreateCache()
 {
     $cache = Cache::createCache('CacheStorageFile', 'TestCache');
 }
开发者ID:ndkhoiits,项目名称:gatein-shindig,代码行数:7,代码来源:CacheFileTest.php


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