本文整理汇总了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);
}
}
示例2: loadSettings
/**
* @return array
*/
private function loadSettings()
{
/** @var Setting $setting */
foreach ($this->repository->findAll() as $setting) {
$this->cache->save($setting->getKey(), $setting->getValue());
}
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}