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


PHP Repository::put方法代码示例

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


在下文中一共展示了Repository::put方法的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: doSave

 /**
  * {@inheritdoc}
  */
 protected function doSave($id, $data, $lifeTime = false)
 {
     if (!$lifeTime) {
         return $this->cache->forever($id, $data);
     }
     return $this->cache->put($id, $data, $lifeTime);
 }
开发者ID:shuaijinchao,项目名称:laravel-doctrine,代码行数:10,代码来源:IlluminateCacheAdapter.php

示例3: put

 /**
  * setter
  *
  * @param string $key     key name
  * @param mixed  $value   the value
  * @param int    $minutes expire time
  * @return void
  */
 public function put($key, $value, $minutes = null)
 {
     if ($minutes == null) {
         $minutes = $this->minutes;
     }
     $this->cache->put($key, $value, $minutes);
 }
开发者ID:mint-soft-com,项目名称:xpressengine,代码行数:15,代码来源:LaravelCache.php

示例4: 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

示例5: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle(Cache $cache)
 {
     $this->info('Calculating stats >>>>>');
     $expiresAt = Carbon::now()->addMinutes(10);
     $tickets = Ticket::withTrashed()->get();
     $openTickets = $tickets->filter(function ($ticket) {
         return !$ticket->trashed();
     });
     $cache->put('tickets.open', $openTickets->count(), $expiresAt);
     $cache->put('tickets.total', $tickets->count(), $expiresAt);
     $this->info('Calculation done and results are cached');
 }
开发者ID:anouarabdsslm,项目名称:micro-service,代码行数:17,代码来源:CacheTicketStats.php

示例6: 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

示例7: run

 /**
  * Run the given event.
  *
  * @param  \Illuminate\Contracts\Container\Container  $container
  * @return mixed
  *
  * @throws \Exception
  */
 public function run(Container $container)
 {
     if ($this->description) {
         $this->cache->put($this->mutexName(), true, 1440);
     }
     try {
         $response = $container->call($this->callback, $this->parameters);
     } finally {
         $this->removeMutex();
     }
     parent::callAfterCallbacks($container);
     return $response;
 }
开发者ID:bryanashley,项目名称:framework,代码行数:21,代码来源:CallbackEvent.php

示例8: save

 /**
  * {@inheritdoc}
  */
 public function save(CacheItemInterface $item)
 {
     $expiresAt = $this->getExpiresAt($item);
     if (!$expiresAt) {
         try {
             $this->repository->forever($item->getKey(), serialize($item->get()));
         } catch (Exception $exception) {
             return false;
         }
         return true;
     }
     $now = new DateTimeImmutable('now', $expiresAt->getTimezone());
     $seconds = $expiresAt->getTimestamp() - $now->getTimestamp();
     $minutes = (int) floor($seconds / 60.0);
     if ($minutes <= 0) {
         $this->repository->forget($item->getKey());
         return false;
     }
     try {
         $this->repository->put($item->getKey(), serialize($item->get()), $minutes);
     } catch (Exception $exception) {
         return false;
     }
     return true;
 }
开发者ID:madewithlove,项目名称:illuminate-psr-cache-bridge,代码行数:28,代码来源:CacheItemPool.php

示例9: 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

示例10: cacheCountBetween

 /**
  * Caches count between if cacheKey is present
  *
  * @param int $count
  * @param Carbon $from
  * @param Carbon $until
  * @param string $locale
  * @param string $cacheKey
  */
 protected function cacheCountBetween($count, Carbon $from, Carbon $until, $locale, $cacheKey)
 {
     // Cache only if cacheKey is present
     if ($cacheKey && $until->timestamp < Carbon::now()->timestamp) {
         $key = $this->makeBetweenCacheKey($from, $until, $locale, $cacheKey);
         $this->cache->put($key, $count, 525600);
     }
 }
开发者ID:kenarkose,项目名称:tracker,代码行数:17,代码来源:Cruncher.php

示例11: 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

示例12: 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

示例13: run

 /**
  * Run the given event.
  *
  * @param  \Illuminate\Contracts\Container\Container  $container
  * @return void
  */
 public function run(Container $container)
 {
     if ($this->withoutOverlapping) {
         $this->cache->put($this->mutexName(), true, 1440);
     }
     if ($this->runInBackground) {
         $this->runCommandInBackground();
     } else {
         $this->runCommandInForeground($container);
     }
 }
开发者ID:jarnovanleeuwen,项目名称:framework,代码行数:17,代码来源:Event.php

示例14: handle

 public function handle(RateFetcher $source, Cache $cache)
 {
     $rates = $source->getUsdRates($this->date);
     if (!count($rates)) {
         throw new ForexException('received empty array of rates');
     }
     $cacheKey = $this->date ? $this->date->format('Y-m-d') : 'live';
     // save rates for two hours to main cache
     $cache->put(ForexService::RATE_CACHE_KEY_PREFIX . $cacheKey, $rates, 120);
     // save rates indefinitely for backup cache
     $cache->forever(ForexService::BACKUP_CACHE_KEY_PREFIX . $cacheKey, $rates);
 }
开发者ID:jonwhittlestone,项目名称:forex-rates,代码行数:12,代码来源:RefetchRatesFromApi.php

示例15: backupColumn

 /**
  * Backup the field type column to cache.
  *
  * @param Blueprint $table
  */
 public function backupColumn(Blueprint $table)
 {
     // Skip if no column type.
     if (!$this->fieldType->getColumnType()) {
         return;
     }
     // Skip if the column doesn't exist.
     if (!$this->schema->hasColumn($table->getTable(), $this->fieldType->getColumnName())) {
         return;
     }
     // Back dat data up.
     $results = $this->connection->table($table->getTable())->select(['id', $this->fieldType->getColumnName()])->get();
     $this->cache->put(__CLASS__ . $this->fieldType->getColumnName(), $results, 10);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:19,代码来源:FieldTypeSchema.php


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