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


PHP CacheManager::get方法代码示例

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


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

示例1: generate

 /**
  * Render weather widget.
  *
  * @param  array  $options
  * @return string
  */
 public function generate($options = array())
 {
     // Get options
     $options = array_merge($this->config['defaults'], $options);
     // Unify units
     $options['units'] = strtolower($options['units']);
     if (!in_array($options['units'], array('metric', 'imperial'))) {
         $options['units'] = 'imperial';
     }
     // Create cache key
     $cacheKey = 'Weather.' . md5(implode($options));
     // Check cache
     if ($this->config['cache'] && $this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     // Get current weather
     $current = $this->getWeather($options['query'], 0, $options['units'], 1);
     if ($current['cod'] !== 200) {
         return 'Unable to load weather';
     }
     // Get forecast
     $forecast = $this->getWeather($options['query'], $options['days'], $options['units']);
     // Render view
     $html = $this->view->make("{$this->config['views']}.{$options['style']}", array('current' => $current, 'forecast' => $forecast, 'units' => $options['units'], 'date' => $options['date']))->render();
     // Add to cache
     if ($this->config['cache']) {
         $this->cache->put($cacheKey, $html, $this->config['cache']);
     }
     return $html;
 }
开发者ID:torann,项目名称:laravel-weather,代码行数:36,代码来源:Weather.php

示例2: get

 /**
  * Get
  * @param $key
  * @return mixed
  */
 public function get($key)
 {
     if ($this->cacheDriver == "file") {
         return $this->cache->get($key);
     }
     return $this->cache->tags($this->tag)->get($key);
 }
开发者ID:MehmetNuri,项目名称:fullycms,代码行数:12,代码来源:FullyCache.php

示例3: get

 /**
  * Returns a setting.
  *
  * @param  string $key
  * @return string
  */
 public function get($key)
 {
     // if the key is cached locally, no need to hit the caching layer
     if (isset($this->settings[$key])) {
         return $this->settings[$key];
     }
     return (string) ($this->settings[$key] = $this->cache->get($this->key($key)));
 }
开发者ID:patkruk,项目名称:laravel-cached-settings,代码行数:14,代码来源:CacheHandler.php

示例4: render

 /**
  * Render the homepage view for displaying.
  *
  * @param  string $name
  * @return string
  */
 public function render($name, $subname = 'Home.Content')
 {
     if ($this->cache->has('home.content')) {
         $content = $this->cache->get('home.content');
     } else {
         $slides = App::make('Lib\\Slides\\SlideRepository')->get();
         $news = App::make('Lib\\News\\NewsRepository')->latest(8);
         $content = $this->view->make($subname)->with('slides', $slides)->with('news', $news)->with('categories', $this->getCategories())->render();
         $this->cache->put('home.content', $content, 2880);
     }
     return $this->view->make($name)->with('content', $content);
 }
开发者ID:onlystar1991,项目名称:mtdb,代码行数:18,代码来源:HomepageRenderer.php

示例5: lookup

 /**
  * Lookup an item in the API.
  *
  * @param string $item
  * @param array  $params
  *
  * @return object
  */
 public function lookup($id, $value = null, $params = array())
 {
     $cacheKey = $this->cacheKey('lookup', $this->getLookupParams($id, $value, $params));
     $cacheDuration = $this->iTunesConfig['cache'];
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     } else {
         return $this->cache->remember($cacheKey, $cacheDuration, function () use($id, $value, $params) {
             return json_encode(parent::lookup($id, $value, $params));
         });
     }
 }
开发者ID:vinelab,项目名称:itunes,代码行数:20,代码来源:LaravelAgent.php

示例6: getCacheLocale

 /**
  * Retrieves a cached locale from the specified locale code.
  *
  * @param string $code
  *
  * @return bool
  */
 protected function getCacheLocale($code)
 {
     $id = sprintf('translation.%s', $code);
     if ($this->cache->has($id)) {
         return $this->cache->get($id);
     }
     return false;
 }
开发者ID:stevebauman,项目名称:translation,代码行数:15,代码来源:Translation.php

示例7: getToken

 /**
  * Get the token credentials for the request.
  *
  * @return \League\OAuth1\Client\Credentials\TokenCredentials
  */
 protected function getToken()
 {
     // We have a stateless app without sessions, so we use the cache to
     // retrieve the temp credentials for man in the middle attack
     // protection
     $key = 'oauth_temp_' . $this->request->get('oauth_token');
     $temp = $this->cache->get($key, '');
     return $this->server->getTokenCredentials($temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier'));
 }
开发者ID:TFidryForks,项目名称:spira,代码行数:14,代码来源:AbstractProvider.php

示例8: getPrice

 /**
  * Return the price of an item using Steam's API
  *
  * @param  integer $appId
  * @param  string  $itemName
  * @param  bool    $onlyPrice Return only the lowest price
  * @return stdClass
  */
 public function getPrice($appId = 730, $itemName, $onlyPrice = false)
 {
     $cacheKey = 'steamprice.item.' . str_slug($itemName);
     // Check if item price is cached
     if ($this->cache->has($cacheKey)) {
         $data = $this->cache->get($cacheKey);
     } else {
         // Grab the item price and cache it
         $url = $this->getItemPriceUrl($itemName, $appId);
         // No result
         if (!($json = @file_get_contents($url))) {
             // Cache null for 30 seconds to not harass the Steam servers
             $this->cache->put($cacheKey, null, 30);
             return null;
         }
         $json = str_replace($this->currencyHtmlTags, '', $json);
         $data = json_decode($json);
         $this->cache->put($cacheKey, $data, Config::get('braseidon.steam-item-prices.cache_time'));
     }
     if ($onlyPrice === true) {
         $data = !isset($data->lowest_price) ? null : $data->lowest_price;
     }
     return $data;
 }
开发者ID:gurzhii,项目名称:steam-item-prices-laravel,代码行数:32,代码来源:ItemPrices.php

示例9: retrieve

 /**
  * Retrieve a value from the cache store.
  *
  * @param string $key
  *
  * @return mixed
  */
 protected function retrieve($key)
 {
     return $this->cache->get($this->key($key));
 }
开发者ID:joselfonseca,项目名称:api,代码行数:11,代码来源:Handler.php

示例10: autoTranslateEnabled

 /**
  * Returns the auto translate configuration option.
  *
  * @return bool
  */
 protected function autoTranslateEnabled()
 {
     return $this->config->get('translation.auto_translate', true);
 }
开发者ID:mohamedsharaf,项目名称:translation-1,代码行数:9,代码来源:Translation.php

示例11: get

 /**
  * Retrieve an item from the cache
  *
  * @param string $key
  *
  * @return mixed
  */
 public function get($key)
 {
     return $this->cache->get($key);
 }
开发者ID:muhamadsyahril,项目名称:ecommerce-1,代码行数:11,代码来源:LaravelCache.php

示例12: retrieveByToken

 /**
  * Retrieve a user by their unique identifier and "remember me" token.
  *
  * @param  mixed $identifier
  * @param  string $token
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveByToken($identifier, $token)
 {
     return $this->cache->get('user' . $identifier . '_token_' . $token, NULL);
 }
开发者ID:flysap,项目名称:administrator,代码行数:11,代码来源:FileUserProvider.php

示例13: get

 public function get($request)
 {
     return $this->cache->get($this->makeCacheKey($request));
 }
开发者ID:antonioribeiro,项目名称:lumen-image-processor,代码行数:4,代码来源:Cache.php

示例14: get

 /**
  * Retrieve an item from the cache by key.
  *
  * @param string|array $key
  * @param mixed $default
  * 
  * @return mixed
  */
 public function get($key, $default = null)
 {
     return $this->cache->get($this->prefix . $key, $default);
 }
开发者ID:it-shura,项目名称:mediawiki-sdk,代码行数:12,代码来源:LaravelCache.php

示例15: forgetMenuMapByKey

 /**
  * forgetMenuMapByKey
  *
  * @param string $menuKey to forget on menu map
  *
  * @return void
  */
 public function forgetMenuMapByKey($menuKey)
 {
     $menuMap = [];
     if ($this->cache->has($this->menuMapKey)) {
         $oldMenuMap = $this->cache->get($this->menuMapKey);
         foreach ($oldMenuMap as $key => $value) {
             if ($key !== $menuKey && $key !== $value) {
                 $menuMap[$key] = $value;
             }
         }
     }
     $this->cache->forever($this->menuMapKey, $menuMap);
 }
开发者ID:mint-soft-com,项目名称:xpressengine,代码行数:20,代码来源:MenuCacheHandler.php


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