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


PHP CacheProvider::save方法代码示例

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


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

示例1: getTcmbData

 /**
  * TCMB sitesi üzerinden XML'i okur.
  *
  * @param Curl $curl
  *
  * @throws Exception\ConnectionFailed
  */
 private function getTcmbData(Curl $curl = null)
 {
     if (is_null($curl)) {
         $curl = new Curl();
     }
     $curl->setOption(CURLOPT_URL, 'http://www.tcmb.gov.tr/kurlar/today.xml');
     $curl->setOption(CURLOPT_HEADER, 0);
     $curl->setOption(CURLOPT_RETURNTRANSFER, 1);
     $curl->setOption(CURLOPT_FOLLOWLOCATION, 1);
     $response = $curl->exec();
     if ($response === false) {
         throw new Exception\ConnectionFailed('Sunucu Bağlantısı Kurulamadı: ' . $curl->error());
     }
     $curl->close();
     $this->data = $this->formatTcmbData((array) simplexml_load_string($response));
     $timezone = new \DateTimeZone('Europe/Istanbul');
     $now = new \DateTime('now', $timezone);
     $expire = $this->data['today'] == $now->format('d.m.Y') ? 'Tomorrow 15:30' : 'Today 15:30';
     $expireDate = new \DateTime($expire, $timezone);
     $this->data['expire'] = $expireDate->getTimestamp();
     if (!is_null($this->cacheDriver)) {
         $lifetime = $expire - $now->getTimestamp();
         // Eğer dosyanın geçerlilik süresi bitmişse veriyi sadece 5 dakika önbellekte tutuyoruz.
         $this->cacheDriver->save($this->cacheKey, $this->data, $lifetime > 0 ? $lifetime : 300);
     }
 }
开发者ID:teknomavi,项目名称:tcmb,代码行数:33,代码来源:Doviz.php

示例2: loadSettings

 /**
  * @return array
  */
 private function loadSettings()
 {
     /** @var Setting $setting */
     foreach ($this->repository->findAll() as $setting) {
         $this->cache->save($setting->getKey(), $setting->getValue());
     }
 }
开发者ID:harentius,项目名称:blog-bundle,代码行数:10,代码来源:SettingsProvider.php

示例3: save

 /**
  * Puts data into the cache.
  *
  * @param string $id       The cache id.
  * @param mixed  $data     The cache entry/data.
  * @param int    $lifeTime The cache lifetime.
  *                         If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime).
  *
  * @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
  */
 public function save($id, $data, $lifeTime = null)
 {
     if (null === $lifeTime) {
         $lifeTime = $this->defaultLifetime;
     }
     return $this->cacheProvider->save($id, $data, $lifeTime);
 }
开发者ID:emilyreese,项目名称:DoctrineCacheExtension,代码行数:17,代码来源:AbstractCacheProviderDecorator.php

示例4: getVersion

 /**
  * @param string $packageName
  * @return string
  */
 public function getVersion($packageName = OroPlatformBundle::PACKAGE_NAME)
 {
     // Get package version from local cache if any
     if (isset($this->packageVersions[$packageName])) {
         return $this->packageVersions[$packageName];
     }
     // Try to get package version from persistent cache
     if ($this->cache && $this->cache->contains($packageName)) {
         $version = $this->cache->fetch($packageName);
     } else {
         // Get package version from composer repository
         $packages = $this->factory->getLocalRepository()->findPackages($packageName);
         if ($package = current($packages)) {
             /** @var PackageInterface $package */
             $version = $package->getPrettyVersion();
         } else {
             $version = self::UNDEFINED_VERSION;
         }
         //Save package version to persistent cache
         if ($this->cache) {
             $this->cache->save($packageName, $version);
         }
     }
     // Save package version to local cache
     $this->packageVersions[$packageName] = $version;
     return $version;
 }
开发者ID:Maksold,项目名称:platform,代码行数:31,代码来源:VersionHelper.php

示例5: setItem

 /**
  * Stores item in Cache.
  *
  * @param \iveeCore\ICacheable $item to be stored
  *
  * @return boolean true on success.
  */
 public function setItem(ICacheable $item)
 {
     $ttl = $item->getCacheExpiry() - time();
     if ($ttl < 1) {
         return false;
     }
     return $this->cache->save($item->getKey(), $item, $ttl);
 }
开发者ID:Covert-Inferno,项目名称:iveeCore,代码行数:15,代码来源:DoctrineCacheWrapper.php

示例6: FetchWithNamespace_StoreInformation

 /**
  * @test
  */
 public function FetchWithNamespace_StoreInformation()
 {
     $this->cacheProvider->save('namespaceId', 'namespace_id');
     $this->cacheProvider->save('namespace_idid', 'data-test');
     $this->decorator->fetchWithNamespace('id', 'namespaceId');
     $this->decorator->fetchWithNamespace('id', 'namespaceId');
     $this->assertCollectedData([new FetchWithNamespaceCacheCollectedData('id', 'namespaceId', 'data-test', 0)], $this->decorator->getCollectedData());
 }
开发者ID:emilyreese,项目名称:DoctrineCacheExtensionBundle,代码行数:11,代码来源:DebugCacheProviderDecoratorTest.php

示例7: get

 /**
  * @return \Heyday\Redirects\Redirect[]
  */
 public function get()
 {
     $key = $this->dataSource->getKey();
     if (!($result = $this->cache->fetch($key))) {
         $this->cache->save($key, $result = $this->dataSource->get());
     }
     return $result;
 }
开发者ID:helpfulrobot,项目名称:heyday-silverstripe-redirects,代码行数:11,代码来源:CachedDataSource.php

示例8: updateTimestamp

 /**
  * Renews the timestamp of the last update of database translations for the given locale
  *
  * @param string|null $locale
  */
 public function updateTimestamp($locale = null)
 {
     if ($locale) {
         $this->localCache[$locale] = (new \DateTime('now', new \DateTimeZone('UTC')))->getTimestamp();
         $this->cacheImpl->save($locale, $this->localCache[$locale]);
     } else {
         $this->localCache = [];
         $this->cacheImpl->deleteAll();
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:DynamicTranslationMetadataCache.php

示例9: canReblog

 /**
  * {@inheritdoc}
  */
 public function canReblog($post)
 {
     $cacheKey = $this->makeCacheKey($post);
     $cached = $this->cache->fetch($cacheKey);
     if ($cached) {
         return false;
     }
     $this->cache->save($cacheKey, '1', $this->term);
     return true;
 }
开发者ID:ushios,项目名称:tumblr,代码行数:13,代码来源:IgnoreDuplicateReblogStrategy.php

示例10: saveCollectInformation

 public function saveCollectInformation($id, $information)
 {
     $this->cache->save($id, $information);
     $indexArray = $this->cache->fetch('index');
     if (empty($indexArray)) {
         $indexArray = [];
     }
     $indexArray[$id] = array_merge($information['request'], $information['response']);
     $this->cache->save('index', $indexArray);
     return $id;
 }
开发者ID:shyim,项目名称:shopware-profiler,代码行数:11,代码来源:Collector.php

示例11: loadSourceData

 /**
  * @return array
  */
 public function loadSourceData()
 {
     if (null === $this->cache) {
         return $this->formatDataLoader->load($this->getUrl());
     }
     $key = $this->getObjectKey();
     if (!$this->cache->contains($key)) {
         $this->cache->save($key, $this->formatDataLoader->load($this->getUrl()), $this->getTtl());
     }
     return $this->cache->fetch($key);
 }
开发者ID:slavamuravey,项目名称:leaderboard-bundle,代码行数:14,代码来源:DataLoader.php

示例12: loadTree

 /**
  * Loads tree data and save them in cache
  */
 protected function loadTree()
 {
     $treeData = new OwnerTree();
     if ($this->checkDatabase()) {
         $this->fillTree($treeData);
     }
     if ($this->cache) {
         $this->cache->save(self::CACHE_KEY, $treeData);
     }
     $this->tree = $treeData;
 }
开发者ID:xamin123,项目名称:platform,代码行数:14,代码来源:OwnerTreeProvider.php

示例13: getCoverImage

 /**
  * Finds first available image for listing purposes
  *
  * @param Content $content
  *
  * @return string
  */
 public function getCoverImage(Content $content)
 {
     $key = $content->getCoverImageCacheKey();
     if (!($image = $this->cache->fetch($key))) {
         $image = $content->getCoverImage();
         if ($image) {
             $image = $this->imageCacheManager->getBrowserPath($image, 'medialibrary');
         }
         $this->cache->save($key, $image, 86400);
     }
     return $image;
 }
开发者ID:Opifer,项目名称:Cms,代码行数:19,代码来源:ContentEventSubscriber.php

示例14: get

 /**
  * @return string
  */
 public function get()
 {
     $key = 'feed';
     if ($this->cache->contains($key)) {
         return $this->cache->fetch($key);
     }
     $articles = $this->articleRepository->findPublishedOrderedByPublishDate();
     $feed = $this->feedManager->get('article');
     $feed->addFromArray($articles);
     $renderedFeed = $feed->render('rss');
     $this->cache->save($key, $renderedFeed);
     return $renderedFeed;
 }
开发者ID:harentius,项目名称:blog-bundle,代码行数:16,代码来源:Feed.php

示例15: getAll

 /**
  * @return array
  */
 public function getAll()
 {
     $key = 'statistics';
     if ($this->cache->contains($key)) {
         return $this->cache->fetch($key);
     }
     $statistics = $this->articleRepository->findStatistics();
     $mostPopularArticle = $this->articleRepository->findMostPopular();
     if ($mostPopularArticle) {
         $statistics['mostPopularArticleData'] = ['slug' => $mostPopularArticle->getSlug(), 'title' => $mostPopularArticle->getTitle(), 'viewsCount' => $mostPopularArticle->getViewsCount()];
     }
     $this->cache->save($key, $statistics, $this->cacheLifetime);
     return $statistics;
 }
开发者ID:harentius,项目名称:blog-bundle,代码行数:17,代码来源:Statistics.php


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