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


PHP Cache::contains方法代码示例

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


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

示例1: indexAction

 /**
  * @Route("/entry-point/{mac}", defaults={"mac" = null})
  * @Method({"GET", "POST"})
  * @Template()
  */
 public function indexAction(Request $request, $mac)
 {
     // Attempting to do anything here as a logged in user will fail. Set the current user token to null to log user out.
     $this->get('security.token_storage')->setToken(null);
     if (!$mac) {
         if (!$request->getSession()->get('auth-data')) {
             // No MAC code, nothing in the session, so we can't help - return to front page.
             return $this->redirectToRoute('barbon_hostedapi_app_index_index');
         }
     } else {
         $cacheKey = sprintf('mac-%s', $mac);
         // If MAC isn't found in the cache, it's already been processed - redirect back to this route without the MAC, and try again.
         if (!$this->cache->contains($cacheKey)) {
             return $this->redirectToRoute('barbon_hostedapi_landlord_authentication_entrypoint_index');
         }
         // store data to session and empty the cache
         $authData = unserialize($this->cache->fetch($cacheKey));
         $request->getSession()->set('auth-data', $authData);
         $this->cache->delete($cacheKey);
     }
     // Decide which tab should start as visible, so that is a registration attempt is in progress it re-shows that tab.
     $selectedTab = $request->query->get('action') ?: 'register';
     if ($request->isMethod(Request::METHOD_POST)) {
         if ($request->request->has('direct_landlord')) {
             $selectedTab = 'register';
         }
     }
     return array('selectedTab' => $selectedTab);
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:34,代码来源:EntryPointController.php

示例2: findAll

 /**
  * @param int $start
  * @param int $maxResults
  * @return Category[]|null
  * @throws RepositoryException
  */
 public function findAll($start = 0, $maxResults = 100)
 {
     $cacheKey = self::CACHE_NAMESPACE . sha1($start . $maxResults);
     if ($this->isCacheEnabled()) {
         if ($this->cache->contains($cacheKey)) {
             return $this->cache->fetch($cacheKey);
         }
     }
     $compiledUrl = $this->baseUrl . "?start_element={$start}&num_elements={$maxResults}";
     $response = $this->client->request('GET', $compiledUrl);
     $repositoryResponse = RepositoryResponse::fromResponse($response);
     if (!$repositoryResponse->isSuccessful()) {
         throw RepositoryException::failed($repositoryResponse);
     }
     $stream = $response->getBody();
     $responseContent = json_decode($stream->getContents(), true);
     $stream->rewind();
     $result = [];
     if (!$responseContent['response']['content_categories']) {
         $responseContent['response']['content_categories'] = [];
     }
     foreach ($responseContent['response']['content_categories'] as $segmentArray) {
         $result[] = Category::fromArray($segmentArray);
     }
     if ($this->isCacheEnabled()) {
         $this->cache->save($cacheKey, $result, self::CACHE_EXPIRATION);
     }
     return $result;
 }
开发者ID:audiens,项目名称:appnexus-client,代码行数:35,代码来源:CategoryRepository.php

示例3: getTimestamp

 public function getTimestamp($key)
 {
     if (!$this->cache->contains($key . ':timestamp')) {
         return (double) 0;
     }
     return floatval($this->cache->fetch($key . ':timestamp'));
 }
开发者ID:beheh,项目名称:flaps,代码行数:7,代码来源:DoctrineCacheAdapter.php

示例4: getContents

 /**
  * Get the contents of an URI and cache it for CACHE_LIFETIME seconds.
  *
  * @param  string  $uri
  * @return string
  */
 public function getContents($uri)
 {
     if (!$this->cache->contains($uri)) {
         $this->cache->save($uri, $contents = $this->download($uri), static::CACHE_LIFETIME);
         return $contents;
     }
     return $this->cache->fetch($uri);
 }
开发者ID:IonutBajescu,项目名称:currency,代码行数:14,代码来源:Downloader.php

示例5: getContext

 /**
  * Returns websocket context for given connection.
  *
  * @param ConnectionInterface $conn
  *
  * @return ConnectionContextInterface
  */
 protected function getContext(ConnectionInterface $conn)
 {
     $id = ConnectionContext::getIdFromConnection($conn);
     if (!$this->contexts->contains($id)) {
         $this->saveContext($this->createContext($conn));
     }
     return $this->contexts->fetch($id);
 }
开发者ID:sulu,项目名称:sulu,代码行数:15,代码来源:AbstractWebsocketApp.php

示例6: internalRemoveItem

 /**
  * {@inheritDoc}
  */
 protected function internalRemoveItem(&$normalizedKey)
 {
     $key = $this->getOptions()->getNamespace() . $normalizedKey;
     if (!$this->cache->contains($key)) {
         return false;
     }
     return $this->cache->delete($key);
 }
开发者ID:antoinealej,项目名称:HomeStuff,代码行数:11,代码来源:DoctrineCacheStorage.php

示例7: fetch

 /**
  * @param string $txid
  * @param int $vout
  * @return Utxo
  */
 public function fetch($txid, $vout)
 {
     $index = $this->getInternalIndex($txid, $vout);
     if (!$this->cache->contains($index)) {
         throw new \RuntimeException('Utxo not found in this cache');
     }
     return $this->cache->fetch($index);
 }
开发者ID:sbwdlihao,项目名称:node-php,代码行数:13,代码来源:UtxoCache.php

示例8: getFromCache

 /**
  * @param $key
  *
  * @throws \LogicException
  *
  * @return bool|mixed
  */
 public function getFromCache($key)
 {
     // If the results are already cached
     if ($this->cache->contains($key)) {
         return unserialize($this->cache->fetch($key));
     }
     return false;
 }
开发者ID:storefactory,项目名称:zoho-subscription-api,代码行数:15,代码来源:Client.php

示例9: remember

 public function remember($key, \closure $callable, $lifeTime = 0)
 {
     if ($this->cache->contains($key)) {
         return $this->cache->fetch($key);
     }
     $data = $callable();
     $this->cache->save($key, $data, $lifeTime);
     return $data;
 }
开发者ID:speedwork,项目名称:cache,代码行数:9,代码来源:CacheNamespace.php

示例10: getIpData

 /**
  * @param string $ip
  * @return Location
  */
 public function getIpData($ip)
 {
     if ($this->storage->contains($ip)) {
         return $this->storage->fetch($ip);
     }
     $result = $this->provider->fetchDataForIp($ip);
     $this->storage->save($ip, $result);
     return $result;
 }
开发者ID:glaubinix,项目名称:geo-ip,代码行数:13,代码来源:GeoIp.php

示例11: addGroupToQueue

 /**
  * @param int $id
  */
 public function addGroupToQueue($id)
 {
     $groupIds = [];
     if ($this->cache->contains(self::QUEUE_CACHE_ID)) {
         $groupIds = $this->cache->fetch(self::QUEUE_CACHE_ID);
     }
     $groupIds[$id] = $id;
     $this->cache->save(self::QUEUE_CACHE_ID, $groupIds);
 }
开发者ID:SURFnet,项目名称:grouphub,代码行数:12,代码来源:QueueService.php

示例12: interpret

 /**
  * {@inheritDoc}
  */
 public function interpret($rule)
 {
     if ($this->cache->contains($rule)) {
         return unserialize($this->cache->fetch($rule));
     }
     $ast = $this->interpreter->interpret($rule);
     $this->cache->save($rule, serialize($ast), $this->lifeTime);
     return $ast;
 }
开发者ID:royopa,项目名称:rulerz,代码行数:12,代码来源:CachedInterpreter.php

示例13: findMatching

 /**
  * {@inheritdoc}
  */
 public function findMatching($route, $host)
 {
     if ($this->cache->contains($this->getCacheKey())) {
         return $this->cache->fetch($this->getCacheKey());
     }
     $rules = $this->ruleProvider->getRules();
     $this->cache->save($this->getCacheKey(), $rules, $this->ttl);
     return $rules;
 }
开发者ID:cdaguerre,项目名称:robots-bundle,代码行数:12,代码来源:CachedRuleProvider.php

示例14: getRolePermissions

 /**
  * {@inheritdoc}
  */
 public function getRolePermissions(Role $role)
 {
     $cacheId = sprintf('roles/%s', $role->getRoleName());
     $permissions = $this->cache->fetch($cacheId);
     if (!$this->cache->contains($cacheId)) {
         $permissions = $this->driver->getRolePermissions($role);
         $this->cache->save($cacheId, $permissions);
     }
     return $permissions;
 }
开发者ID:guardianphp,项目名称:lock-cache,代码行数:13,代码来源:DoctrineCacheDriver.php

示例15: getThumbnail

 /**
  * Returns thumbnail data for the given transaction.
  *
  * Handles the cache layer around the creation as well.
  *
  * @param Transaction $transaction
  *
  * @return string
  */
 protected function getThumbnail(Transaction $transaction)
 {
     $cacheKey = $transaction->getHash();
     if ($this->cache->contains($cacheKey)) {
         return $this->cache->fetch($cacheKey);
     }
     $imageData = $this->creator->create($transaction);
     $this->cache->save($cacheKey, $imageData, $this->cacheTime);
     return $imageData;
 }
开发者ID:pkdevboxy,项目名称:bolt-thumbs,代码行数:19,代码来源:Responder.php


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