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


PHP Repository::put方法代码示例

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


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

示例1: put

 /**
  * Cache the key value till 12am
  *
  * @param  string  $key
  * @param  mixed  $value
  * @return void
  */
 public static function put($key, $value)
 {
     $today = strtotime(date('Ymd'));
     $key = "{$today}.{$key}";
     $minutes = (int) date('i');
     $total_minutes_today = date('G') * 60 + $minutes;
     $minutes_till_midnight = 1440 - $total_minutes_today;
     static::$cache->put($key, $value, $minutes_till_midnight);
 }
开发者ID:jaggy,项目名称:work-scripts,代码行数:16,代码来源:Cache.php

示例2: postAuthorized

 /**
  * Handles authenticating that a user/character is still valid.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function postAuthorized()
 {
     // Get the neccessary headers from the request.
     $service = $this->request->header('service', false);
     $username = $this->request->header('username', '');
     $character = $this->request->header('character', '');
     $this->log->info('A service is attempting to validate a user.', ['username' => $username, 'character' => $character, 'service' => $service]);
     // Verify that the external service exists in the configuration.
     if (!$service || !$this->config->get("addon.auth.{$service}")) {
         $this->log->info(self::ERROR_INVALID_EXTERNAL_SERVICE, ['service' => $service]);
         return $this->failure(self::ERRNO_INVALID_EXTERNAL_SERVICE, self::ERROR_INVALID_EXTERNAL_SERVICE);
     }
     // Check the cache first so the api isn't hammered too badly.
     $key = 'auth:session:' . sha1("{$service}:{$username}");
     if ($this->cache->has($key)) {
         $this->log->info('Returning the cached authorization result.');
         return $this->cache->get($key);
     }
     // Attempt to find the requested user.
     $identifier = filter_var($username, FILTER_VALIDATE_EMAIL) ? 'email' : 'name';
     $user = $this->users->where($identifier, $username)->first() ?: false;
     if (!$user) {
         $this->log->info(self::ERROR_USER_NOT_FOUND);
         return $this->failure(self::ERRNO_USER_NOT_FOUND, self::ERROR_USER_NOT_FOUND);
     }
     // Get and cache the response for 15 minutes.
     $response = $this->getLoginResult($user, $service, $character);
     $this->cache->put($key, $response, $this->carbon->now()->addMinutes(15));
     return $response;
 }
开发者ID:msims04,项目名称:eveseat-addon-auth,代码行数:35,代码来源:AuthController.php

示例3: image

 public function image(Repository $cache, $id)
 {
     if ($cache->has($id)) {
         return $cache->get($id);
     }
     $card = base64_encode(file_get_contents('http://magiccards.info/scans/en/ori/' . $id . '.jpg'));
     $cache->put($id, $card, 60);
     return $card;
 }
开发者ID:NukaCode,项目名称:Magic,代码行数:9,代码来源:HomeController.php

示例4: saveCachedView

 /**
  * Save a cached view if caching is enabled.
  *
  * @param  \Illuminate\Http\Response  $response
  * @return void
  */
 protected function saveCachedView(Response $response)
 {
     if (config('sitemap.cache_enabled')) {
         $key = $this->getCacheKey();
         $content = $response->getOriginalContent()->render();
         if (!$this->cache->get($key)) {
             $this->cache->put($key, $content, config('sitemap.cache_length'));
         }
     }
 }
开发者ID:shaggyz,项目名称:sitemap,代码行数:16,代码来源:Sitemap.php

示例5: make

 /**
  * Generate thumbnail.
  *
  * @param $src
  * @param $width
  * @param $height
  *
  * @throws \RuntimeException
  * @return Thumbnail
  */
 public function make($src, $width, $height)
 {
     if ($src === null || $width === null && $height === null) {
         throw new \RuntimeException();
     }
     $key = md5($src . 'w' . $width . 'h' . $height);
     if (!($image = $this->cache->get($key))) {
         $image = $this->image->make($src);
         $image->resize($width, $height, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
         if ($width === null) {
             $width = $image->getWidth();
         }
         if ($height === null) {
             $height = $image->getHeight();
         }
         $image->resizeCanvas($width, $height, 'center', false, 'ffffff');
         $image = (string) $image->encode('jpg');
         $this->cache->put($key, $image, $this->lifetime);
     }
     return new Thumbnail($key, $image, $this->expires(), 'image/jpeg');
 }
开发者ID:guratr,项目名称:cruddy,代码行数:34,代码来源:ThumbnailFactory.php

示例6: put

 /**
  * Store an item in the cache.
  *
  * @param string $key
  * @param mixed $value
  * @param \DateTime|int $minutes
  * @return void 
  * @static 
  */
 public static function put($key, $value, $minutes)
 {
     \Illuminate\Cache\Repository::put($key, $value, $minutes);
 }
开发者ID:satriashp,项目名称:tour,代码行数:13,代码来源:_ide_helper.php

示例7: put

 /**
  * Store an item in the cache.
  *
  * @param  mixed  $key
  * @param  mixed  $value
  * @param  \DateTime|int  $minutes
  * @return void
  */
 public function put($key, $value, $minutes)
 {
     if (is_array($key) && is_array($value)) {
         $this->putMany(array_combine($key, $value), $minutes);
     } else {
         parent::put($key, $value, $minutes);
     }
 }
开发者ID:pulkitjalan,项目名称:multicache,代码行数:16,代码来源:Repository.php

示例8: put

 /**
  * @param string                    $key
  * @param \Illuminate\Http\Response $response
  * @param \DateTime|int             $minutes
  */
 public function put($key, $response, $minutes)
 {
     $this->cache->put($key, $this->responseSerializer->serialize($response), $minutes);
 }
开发者ID:sdebacker,项目名称:laravel-responsecache,代码行数:9,代码来源:ResponseCacheRepository.php

示例9: write

 /**
  * {@inheritDoc}
  */
 public function write($sessionId, $data)
 {
     return $this->cache->put($sessionId, $data, $this->minutes);
 }
开发者ID:rodrigopbel,项目名称:ong,代码行数:7,代码来源:CacheBasedSessionHandler.php

示例10: putCodeToCache

 /**
  * 保存验证码到缓存中
  * @param string $mobile
  * @param string $code
  * @param string $bag
  * @return \Illuminate\Cache\void
  */
 public function putCodeToCache($mobile, $code, $bag)
 {
     $key = $this->getCacheKey($mobile, $bag);
     return $this->store->put($key, $code, $this->cacheMinutes);
 }
开发者ID:windqyoung,项目名称:utils,代码行数:12,代码来源:VCode.php

示例11: setToken

 /**
  * Setter for token
  *
  * @param string $key
  * @param string $value
  * @param int $duration
  */
 public function setToken($key, $value, $duration = 60)
 {
     $this->cache->put('reactor.tokens.' . $key, $value, $duration);
 }
开发者ID:NuclearCMS,项目名称:Hierarchy,代码行数:11,代码来源:TokenManager.php

示例12: put

 /**
  * @param $content
  * @return mixed
  */
 public function put($key, $content)
 {
     if ($this->enabled) {
         return $this->cache->put($key, $content, $this->getCacheLifetime());
     }
 }
开发者ID:coandacms,项目名称:coanda-core,代码行数:10,代码来源:PageStaticCacher.php

示例13: updateInverseIndex

 /**
  * Updates the inverse index for the given cache key.
  *
  * @param  string             $key
  * @param  \DateTime|int|null $minutes
  */
 protected function updateInverseIndex($key, $minutes = null)
 {
     $this->setKeywordsOperation(true);
     $keywordsState = $this->determineKeywordsState($key);
     $inverseIndexKey = $this->generateInverseIndexKey($key);
     if (empty($keywordsState['new'])) {
         parent::forget($inverseIndexKey);
     } elseif ($keywordsState['old'] != $keywordsState['new']) {
         $newInverseIndex = array_values($keywordsState['new']);
         is_null($minutes) ? parent::forever($inverseIndexKey, $newInverseIndex) : parent::put($inverseIndexKey, $newInverseIndex, $minutes);
     }
     $this->setKeywordsOperation(false);
 }
开发者ID:propaganistas,项目名称:laravel-cache-keywords,代码行数:19,代码来源:KeywordsRepository.php

示例14: put

 /**
  * Store an item in the cache.
  *
  * @param  string        $key
  * @param  mixed         $value
  * @param  \DateTime|int $minutes
  *
  * @return void
  */
 public function put($key, $value, $minutes)
 {
     if ($this->enabled) {
         $this->cache->put($key, $value, $minutes);
     }
 }
开发者ID:wegnermedia,项目名称:melon,代码行数:15,代码来源:Cacher.php

示例15: storeResultInCache

 /**
  * @param $result
  */
 public function storeResultInCache($result)
 {
     $this->cache->put($this->actualQueryHash, $result, $this->cacheLifeTime);
 }
开发者ID:Algatux,项目名称:laravel-repository,代码行数:7,代码来源:CacheManager.php


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