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


PHP Cache\Repository类代码示例

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


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

示例1: handle

 /**
  * Handle the form.
  *
  * @param Repository $cache
  * @param Redirector $redirect
  * @param            $key
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function handle(Repository $cache, Redirector $redirect, $key)
 {
     $parameters = $cache->get('form::' . $key);
     $criteria = $this->dispatch(new GetFormCriteria($parameters));
     /* @var FormBuilder $builder */
     $builder = $criteria->builder();
     $response = $builder->build()->post()->getFormResponse();
     $builder->flash();
     if ($response && $response->getStatusCode() !== 200) {
         return $response;
     }
     if ($builder->hasFormErrors()) {
         return $redirect->back();
     }
     return $response ?: $redirect->back();
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:24,代码来源:FormController.php

示例2: search

 public function search(Repository $cache, $search = 'enchantment')
 {
     $client = new Client(config('algolia.connections.main.id'), config('algolia.connections.main.key'));
     //if ($cache->has('origins.'. $search)) {
     //    $cards = $cache->get($search);
     //} else {
     $index = $client->initIndex(config('algolia.index'));
     $index->setSettings(['attributesForFaceting' => ['colors', 'multiverseid']]);
     $cards = $index->search($search, ['facets' => '*', 'facetFilters' => 'colors:Green'])['hits'];
     foreach ($cards as $index => $card) {
         if (isset($card['manaCost'])) {
             $cards[$index]['manaCost'] = preg_replace('/{(.)}/', '<img src="/images/blank.png" id="$1" />', $card['manaCost']);
         }
     }
     $cache->forever($search, $cards);
     //}
     $this->setJavascriptData(compact('cards'));
 }
开发者ID:NukaCode,项目名称:Magic,代码行数:18,代码来源:HomeController.php

示例3: save

 public function save()
 {
     // New and changed keys
     $changed = array_diff_assoc($this->data, $this->original);
     $insertValues = array();
     foreach ($changed as $name => $value) {
         if (!array_key_exists($name, $this->original)) {
             $insertValues[] = array('conf_name' => $name, 'conf_value' => $value);
             unset($changed[$name]);
         }
     }
     if (!empty($insertValues)) {
         $this->database->table('config')->insert($insertValues);
     }
     foreach ($changed as $name => $value) {
         $this->database->table('config')->where('conf_name', '=', $name)->update(array('conf_value' => $value));
     }
     // Deleted keys
     $deletedKeys = array_keys(array_diff_key($this->original, $this->data));
     if (!empty($deletedKeys)) {
         $this->database->table('config')->whereIn('conf_name', $deletedKeys)->delete();
     }
     // No need to cache old values anymore
     $this->original = $this->data;
     // Delete the cache so that it will be regenerated on the next request
     $this->cache->forget('fluxbb.config');
 }
开发者ID:fluxbb,项目名称:core,代码行数:27,代码来源:ConfigRepository.php

示例4: cache

 /**
  * Get info from a specify url and cache that using laravel cache manager.
  *
  * @param  string $url
  * @param  null|array $options
  * @return mixed
  */
 public function cache($url, array $options = null)
 {
     $lifetime = array_get($options, 'lifetime', 60);
     array_forget($options, 'lifetime');
     $self = $this;
     return $this->cache->remember($url, $lifetime, function () use($self, $url, $options) {
         return $self->get($url, $options);
     });
 }
开发者ID:lokconnect,项目名称:oembed,代码行数:16,代码来源:Oembed.php

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

示例6: format

 /**
  * {@inheritdoc}
  */
 protected function format($string)
 {
     if (!$this->watch) {
         $key = 'js.' . sha1($string);
         $string = $this->cache->rememberForever($key, function () use($string) {
             return $this->minify($string);
         });
     }
     return $string . ";\n";
 }
开发者ID:clops,项目名称:core,代码行数:13,代码来源:JsCompiler.php

示例7: cached

 /**
  * Returns the cached content if NOT running locally.
  *
  * @param  string $key
  * @param  mixed  $value
  * @param  int    $time
  * @return mixed
  */
 private function cached($key, $value, $time = 5)
 {
     if (App::environment('local') === false) {
         return $this->cache->remember($key, $time, function () use($value) {
             return $value;
         });
     } else {
         return $value;
     }
 }
开发者ID:nothing-fr,项目名称:legacy-codex,代码行数:18,代码来源:CacheTrait.php

示例8: getColumnsOnCache

 /**
  * To get all columns on caching
  * 
  * @param \Illuminate\Database\Eloquent\Model $model
  * @return array
  */
 protected function getColumnsOnCache(Model $model)
 {
     /**
      * In normal scenario tables and  columns often is not changed. 
      * Therefore every time it is not need to access the database for knowing 
      * columns name. We don't want make preoccupy/busy to the database. 
      */
     $fullKey = $this->getFullName($model);
     return $this->cache->remember($fullKey, $this->getRememberTime(), function () use($model) {
         return $this->builder->getColumnListing($model->getTable());
     });
 }
开发者ID:muratsplat,项目名称:multilang,代码行数:18,代码来源:CheckerAttribute.php

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

示例10: get

 /**
  * Retrieve an item from the cache by key. If the item is about to expire soon,
  * extend the existing cache entry (for other requests) before returning the item
  *
  * @param  string  $key
  * @param  mixed   $default
  * @return mixed
  */
 public function get($key, $default = null)
 {
     while ($this->cacheFlagExists($key)) {
         sleep($this->sleep);
     }
     return parent::get($key, $default);
 }
开发者ID:pyrello,项目名称:laravel-extended-cache,代码行数:15,代码来源:Repository.php

示例11: save

 /**
  * {@inheritdoc}
  */
 public function save($key, CacheEntry $data)
 {
     try {
         $lifeTime = $data->getTTL();
         if ($lifeTime === 0) {
             return $this->cache->forever($key, serialize($data));
         } else {
             if ($lifeTime > 0) {
                 return $this->cache->add($key, serialize($data), $lifeTime);
             }
         }
     } catch (\Exception $ignored) {
         // No fail if we can't save it the storage
     }
     return false;
 }
开发者ID:kevinrob,项目名称:guzzle-cache-middleware,代码行数:19,代码来源:LaravelCacheStorage.php

示例12: getSubTitle

 /**
  * Get the page sub title
  *
  * @param string $page
  * @return string
  */
 public function getSubTitle($page)
 {
     $pageFile = $this->getDocumentationPath() . "/{$page}.md";
     return $this->cache->rememberForever("doc_page_{$pageFile}_sub-title", function () use($pageFile) {
         $data = $this->parser->parse($this->finder->get($pageFile));
         return $data->get('subtitle');
     });
 }
开发者ID:Houbsi,项目名称:Website,代码行数:14,代码来源:GitDocumentationRepository.php

示例13: getInstalledThemes

 /**
  * Retrives the installed themes from the cache.
  *
  * If the cahce entry doesn't exist then it is created.
  *
  * @return array
  */
 public function getInstalledThemes()
 {
     $installed = $this->cache->get($this->cacheKey);
     if ($installed !== null) {
         return $installed;
     }
     return $this->findAndInstallThemes();
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:15,代码来源:Manager.php

示例14: makeCacheKey

 /**
  * make a cache key
  *
  * @param string $key
  * @param string $prefix
  * @return string
  */
 private function makeCacheKey($key, $prefix = '')
 {
     $key = md5($prefix . $key);
     $keys = $this->cache->get(self::CACHE_KEYS_KEY, []);
     $keys[$key] = $key;
     $this->cache->forever(self::CACHE_KEYS_KEY, $keys);
     return $key;
 }
开发者ID:rokde,项目名称:laravel-query-analyzer,代码行数:15,代码来源:QueryRepository.php

示例15: testShouldReturnNullFlushRecord

 public function testShouldReturnNullFlushRecord()
 {
     $this->repository->add('memcached-testing', 'couchbase', 60);
     $this->repository->decrement('memcached-testing-decrement', 100);
     $this->repository->increment('memcached-testing-increment', 100);
     $this->repository->flush();
     $this->assertNull($this->repository->get('memcached-testing'));
     $this->assertNull($this->repository->get('memcached-testing-decrement'));
     $this->assertNull($this->repository->get('memcached-testing-increment'));
 }
开发者ID:ytake,项目名称:laravel-couchbase,代码行数:10,代码来源:MemcachedBucketTest.php


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