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


PHP Repository::get方法代码示例

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


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

示例1: authenticate

 /**
  * @return string Access token
  */
 public function authenticate()
 {
     if (!$this->repository->has('brightcove.bearer')) {
         $this->repository->put('brightcove.bearer', $this->brightcove->authenticate(), $this->duration);
     }
     return $this->repository->get('brightcove.bearer');
 }
开发者ID:ronaldcastillo,项目名称:brightcove,代码行数:10,代码来源:BrightCoveCacheDecorator.php

示例2: getItem

 /**
  * {@inheritdoc}
  */
 public function getItem($key)
 {
     $this->validateKey($key);
     if ($this->repository->has($key)) {
         return new CacheItem($key, unserialize($this->repository->get($key)), true);
     } else {
         return new CacheItem($key);
     }
 }
开发者ID:richlove1,项目名称:avc-october,代码行数:12,代码来源:CacheItemPool.php

示例3: getNews

 public function getNews()
 {
     $key = 'boomcms.news';
     return $this->cache->get($key, function () use($key) {
         $response = json_decode(@file_get_contents($this->newsUrl));
         $news = $response->news ?? [];
         $this->cache->put($key, $news, 3600);
         return $news;
     });
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:10,代码来源:BoomCMS.php

示例4: check

 public function check($value)
 {
     $result = false;
     if ($this->store->has('captcha')) {
         $captchaStore = $this->store->get('captcha');
         $result = $captchaStore->check($value);
         $this->store->forever('captcha', $captchaStore);
     }
     return $result;
 }
开发者ID:disik69,项目名称:backend.english-roulette-v0.3,代码行数:10,代码来源:Captcha.php

示例5: all

 /**
  * Get the dataset collection
  *
  * @return \Illuminate\Support\Collection
  */
 public function all()
 {
     $cacheKey = 'dataset' . (new ReflectionClass($this))->getShortName();
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     $dataset = $this->cache->rememberForever($cacheKey, function () {
         return $this->getDataset();
     });
     return $dataset;
 }
开发者ID:TFidryForks,项目名称:spira,代码行数:16,代码来源:Dataset.php

示例6: getTeamInfo

 /**
  * @return array
  */
 public function getTeamInfo()
 {
     /**
      * @var array|null $cached
      */
     $cached = $this->cache->get(self::SLACK_TEAM_INFO_KEY);
     if (!$cached) {
         $cached = $this->refreshTeamInfo();
     }
     return $cached;
 }
开发者ID:vluzrmos,项目名称:lumen-slackin,代码行数:14,代码来源:SlackStatusService.php

示例7: getItem

 /**
  * {@inheritdoc}
  */
 public function getItem($key)
 {
     $this->validateKey($key);
     if (isset($this->deferred[$key])) {
         return clone $this->deferred[$key];
     } elseif ($this->repository->has($key)) {
         return new CacheItem($key, unserialize($this->repository->get($key)), true);
     } else {
         return new CacheItem($key);
     }
 }
开发者ID:madewithlove,项目名称:illuminate-psr-cache-bridge,代码行数:14,代码来源:CacheItemPool.php

示例8: performRealTimeQuery

 /**
  * Query the Google Analytics Real Time Reporting Service with given parameters.
  *
  * @param int    $id
  * @param string $metrics
  * @param array  $others
  *
  * @return mixed
  */
 public function performRealTimeQuery($id, $metrics, array $others = [])
 {
     $realTimeCacheName = $this->determineRealTimeCacheName(func_get_args());
     if ($this->useRealTimeCache() && $this->cache->has($realTimeCacheName)) {
         return $this->cache->get($realTimeCacheName);
     }
     $googleAnswer = $this->service->data_realtime->get($id, $metrics, $others);
     if ($this->useRealTimeCache()) {
         $this->cache->put($realTimeCacheName, $googleAnswer, Carbon::now()->addSeconds($this->realTimeCacheLifeTimeInSeconds));
     }
     return $googleAnswer;
 }
开发者ID:rtcustom,项目名称:laravel-analytics,代码行数:21,代码来源:GoogleApiHelper.php

示例9: retrieveById

 /**
  * @param mixed $identifier
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveById($identifier)
 {
     $cacheKey = "user:{$identifier}";
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     $result = $this->createModel()->newQuery()->find($identifier);
     if (is_null($result)) {
         return null;
     }
     $this->cache->add($cacheKey, $result, 120);
     return $result;
 }
开发者ID:nazonohito51,项目名称:laravel-jp-reference-chapter8,代码行数:17,代码来源:UserCacheProvider.php

示例10: load

 protected function load()
 {
     // load from cache
     if ($this->cache) {
         $map = $this->cache->get('vat-rates');
     }
     // fetch from jsonvat.com
     if (empty($map)) {
         $map = $this->fetch();
         // store in cache
         if ($this->cache) {
             $this->cache->put('vat-rates', $map, 86400);
         }
     }
     return $map;
 }
开发者ID:dannyvankooten,项目名称:laravel-vat,代码行数:16,代码来源:Rates.php

示例11: getBranchesToSync

 public function getBranchesToSync()
 {
     $allowedBranches = $this->setting('sync.constraints.branches');
     if (count($allowedBranches) === 0) {
         return [];
     }
     $this->fire('git.syncer.branches.start', [$allowedBranches]);
     $branchesToSync = [];
     $remote = $this->client($this->setting('remote'));
     $repo = $this->setting('repository');
     $owner = $this->setting('owner');
     $branches = $remote->getBranches($repo, $owner);
     foreach ($branches as $branch => $sha) {
         if (!in_array('*', $allowedBranches, true) and !in_array($branch, $allowedBranches, true)) {
             continue;
         }
         $cacheKey = md5($this->project->getName() . $branch);
         $cached = $this->cache->get($cacheKey, false);
         $destinationPath = Path::join($this->project->getPath(), $branch);
         if ($cached !== $sha || $cached === false || !$this->files->exists($destinationPath)) {
             $branchesToSync[] = $branch;
         }
     }
     $this->fire('git.syncer.branches.finish', [$branchesToSync]);
     return $branchesToSync;
 }
开发者ID:codex-project,项目名称:git-hook,代码行数:26,代码来源:Syncer.php

示例12: getTimestampRestartCommand

 /**
  * Get the last restart timestamp, or null.
  *
  * @return int|null
  */
 protected function getTimestampRestartCommand()
 {
     if ($this->cache) {
         return $this->cache->get(self::restartID);
     }
     return null;
 }
开发者ID:consolle,项目名称:framework,代码行数:12,代码来源:Daemon.php

示例13: handle

 /**
  * Handle the command.
  *
  * @param Repository                     $cache
  * @param Request                        $request
  * @param UserAuthenticator              $authenticator
  * @param SettingRepositoryInterface     $settings
  * @param ThrottleSecurityCheckExtension $extension
  * @return bool
  */
 public function handle(Repository $cache, Request $request, UserAuthenticator $authenticator, SettingRepositoryInterface $settings, ThrottleSecurityCheckExtension $extension)
 {
     $maxAttempts = $settings->value('anomaly.extension.throttle_security_check::max_attempts', 5);
     $lockoutInterval = $settings->value('anomaly.extension.throttle_security_check::lockout_interval', 1);
     $throttleInterval = $settings->value('anomaly.extension.throttle_security_check::throttle_interval', 1);
     $attempts = $cache->get($extension->getNamespace('attempts:' . $request->ip()), 1);
     $expiration = $cache->get($extension->getNamespace('expiration:' . $request->ip()));
     if ($expiration || $attempts >= $maxAttempts) {
         $cache->put($extension->getNamespace('attempts:' . $request->ip()), $attempts + 1, $throttleInterval);
         $cache->put($extension->getNamespace('expiration:' . $request->ip()), time(), $lockoutInterval);
         $authenticator->logout();
         // Just for safe measure.
         return $this->dispatch(new MakeResponse());
     }
     $cache->put($extension->getNamespace('attempts:' . $request->ip()), $attempts + 1, $throttleInterval);
     return true;
 }
开发者ID:visualturk,项目名称:throttle_security_check-extension,代码行数:27,代码来源:ThrottleLogin.php

示例14: getProfileFromWatson

 /**
  * Get Full Insights From Watson API.
  *
  * @throws \FindBrok\WatsonBridge\Exceptions\WatsonBridgeException
  *
  * @return \Illuminate\Support\Collection
  */
 public function getProfileFromWatson()
 {
     //We have the request in cache and cache is on
     if ($this->cacheIsOn() && $this->cache->has($this->getContainer()->getCacheKey())) {
         //Return results from cache
         return $this->cache->get($this->getContainer()->getCacheKey());
     }
     //Cross the bridge
     $response = $this->makeBridge()->post('v2/profile', $this->getContainer()->getContentsForRequest());
     //Decode profile
     $profile = collect(json_decode($response->getBody()->getContents(), true));
     //Cache results if cache is on
     if ($this->cacheIsOn()) {
         $this->cache->put($this->getContainer()->getCacheKey(), $profile, $this->cacheLifetime());
     }
     //Return profile
     return $profile;
 }
开发者ID:findbrok,项目名称:laravel-personality-insights,代码行数:25,代码来源:PersonalityInsights.php

示例15: retrieveById

 /**
  * Authコンポーネントのuser()メソッドなどを利用した場合に実行されるメソッドです
  * デフォルトの場合、user()メソッドコール時に都度SQLが発行されますので、cacheを利用します。
  * ユーザー情報更新時などにcacheを再生成するように実装します。
  *
  * @param  mixed $identifier
  *
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveById($identifier)
 {
     /**
      * user:$identifier(user_id) としてキャッシュを検索し、
      * 見つからない場合は作成してデータベースから取得したデータを保持します
      * 以降はデータベースへアクセスしません
      */
     $cacheKey = "user:{$identifier}";
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     $result = $this->createModel()->newQuery()->find($identifier);
     if (is_null($result)) {
         return null;
     }
     $this->cache->add($cacheKey, $result, 120);
     return $result;
 }
开发者ID:laravel-jp-reference,项目名称:chapter8,代码行数:27,代码来源:UserCacheProvider.php


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