• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Cache\Repository类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Repository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: repository

 /**
  * Create a new cache repository with the given implementation.
  *
  * @param  \Illuminate\Contracts\Cache\Store  $store
  * @return \Illuminate\Cache\Repository
  */
 public function repository(Store $store)
 {
     $repository = new Repository($store);
     if ($this->app->bound('Illuminate\\Contracts\\Events\\Dispatcher')) {
         $repository->setEventDispatcher($this->app['Illuminate\\Contracts\\Events\\Dispatcher']);
     }
     return $repository;
 }
开发者ID:davidhemphill,项目名称:framework,代码行数:14,代码来源:CacheManager.php


示例4: ConfigRepository

Illuminate\Container\Container::setInstance($app);
if (file_exists($configFile = __DIR__ . '/../config.php')) {
    $app->instance('flarum.config', include $configFile);
}
date_default_timezone_set('UTC');
$app->instance('config', $config = new ConfigRepository(['view' => ['paths' => [realpath(base_path('resources/views'))], 'compiled' => realpath(storage_path() . '/framework/views')], 'mail' => ['driver' => 'mail'], 'cache' => ['default' => 'file', 'stores' => ['file' => ['driver' => 'file', 'path' => storage_path() . '/framework/cache']], 'prefix' => 'flarum'], 'filesystems' => ['default' => 'local', 'cloud' => 's3', 'disks' => ['flarum-avatars' => ['driver' => 'local', 'root' => public_path('assets/avatars')]]]]));
$logger = new Monolog\Logger($app->environment());
$logPath = $app->storagePath() . '/logs/flarum.log';
$handler = new \Monolog\Handler\StreamHandler($logPath, Monolog\Logger::DEBUG);
$handler->setFormatter(new \Monolog\Formatter\LineFormatter(null, null, true, true));
$logger->pushHandler($handler);
$app->instance('log', $logger);
$app->alias('log', 'Psr\\Log\\LoggerInterface');
$app->singleton('cache', function ($app) {
    $store = new FileStore(new Filesystem(), storage_path('framework/cache'));
    $repository = new Repository($store);
    $repository->setEventDispatcher($app->make('events'));
    return $repository;
});
$app->alias('cache', 'Illuminate\\Contracts\\Cache\\Repository');
$serviceProviders = ['Flarum\\Core\\DatabaseServiceProvider', 'Flarum\\Core\\Settings\\SettingsServiceProvider', 'Flarum\\Locale\\LocaleServiceProvider', 'Illuminate\\Bus\\BusServiceProvider', 'Illuminate\\Filesystem\\FilesystemServiceProvider', 'Illuminate\\Hashing\\HashServiceProvider', 'Illuminate\\Mail\\MailServiceProvider', 'Illuminate\\View\\ViewServiceProvider', 'Illuminate\\Events\\EventServiceProvider', 'Illuminate\\Validation\\ValidationServiceProvider'];
foreach ($serviceProviders as $provider) {
    $app->register(new $provider($app));
}
if (Core::isInstalled()) {
    $settings = $app->make('Flarum\\Core\\Settings\\SettingsRepository');
    $app->register(new \Flarum\Core\CoreServiceProvider($app));
    $config->set('mail.driver', Core::config('mail_driver'));
    $config->set('mail.host', Core::config('mail_host'));
    $config->set('mail.port', Core::config('mail_port'));
    $config->set('mail.from.address', Core::config('mail_from'));
开发者ID:noname007,项目名称:flarum,代码行数:31,代码来源:bootstrap.php


示例5: macroCall

 /**
  * Dynamically handle calls to the class.
  *
  * @param string $method
  * @param array $parameters
  * @return mixed 
  * @throws \BadMethodCallException
  * @static 
  */
 public static function macroCall($method, $parameters)
 {
     return \Illuminate\Cache\Repository::macroCall($method, $parameters);
 }
开发者ID:satriashp,项目名称:tour,代码行数:13,代码来源:_ide_helper.php


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


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


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


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


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


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


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


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


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


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


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


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


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


示例19: getRealmData

 /**
  * @return Realm
  */
 public function getRealmData()
 {
     $that = $this;
     return $this->cache->get('ekko:static:realm', function () use($that) {
         $data = $this->ekko->data()->getRealm();
         $that->cache->add('ekko:static:realm', $data, 60 * 24 * 7);
         return $data;
     });
 }
开发者ID:Itrulia,项目名称:MatchHistory,代码行数:12,代码来源:StaticDataService.php


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Config\Repository类代码示例发布时间:2022-05-23
下一篇:
PHP Cache\FileStore类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap