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


PHP Cache::store方法代码示例

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


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

示例1: __construct

 /**
  * @param CoreInterface $core
  */
 public function __construct(CoreInterface $core)
 {
     $this->core = $core;
     $cache = IlluminateCache::store($this->getCacheStore());
     if ($tags = $this->getCacheTags()) {
         $cache = $cache->tags($tags);
     }
     $this->cache = $cache;
 }
开发者ID:czim,项目名称:laravel-cms-core,代码行数:12,代码来源:Cache.php

示例2: __construct

 public function __construct(Database $database, $cacheName = null, $lifetime = null)
 {
     $this->database = $database;
     if ($cacheName) {
         $this->cache = Cache::store($cacheName);
         $this->lifetime = $lifetime;
     } else {
         $this->cache = null;
         $this->lifetime = 0;
     }
 }
开发者ID:meshkorea,项目名称:laravel-postcodify,代码行数:11,代码来源:Service.php

示例3: getArticle

 public function getArticle($id)
 {
     return Cache::store($this->store)->rememberForever($id, function () use($id) {
         $article_model = new Articles();
         $article = $article_model->published()->getById($id)->with('tags', 'category')->first();
         $data = ['id' => $article->id, 'title' => $article->title, 'curl' => $article->curl, 'keywords' => $article->meta_keywords, 'description' => $article->meta_description, 'content' => $article->content, 'created_at' => $article->created_at, 'updated_at' => $article->updated_at, 'is_comments' => $article->comments_enable, 'category' => ['id' => $article->category->id, 'name' => $article->category->name, 'curl' => $article->category->curl]];
         foreach ($article->tags as $tag) {
             $data['tags'][] = ['id' => $tag->id, 'name' => $tag->name, 'curl' => $tag->curl];
         }
         return $data;
     });
 }
开发者ID:panfillich,项目名称:myblog,代码行数:12,代码来源:Article.php

示例4: getCommentsByIdArticle

 public function getCommentsByIdArticle($id)
 {
     return Cache::store($this->store)->rememberForever($id, function () use($id) {
         $data = [];
         $comments_model = new CommentsModel();
         $comments = $comments_model->published()->commentsByArticleId($id)->orderByParam()->get();
         foreach ($comments as $coment) {
             $data[] = ['id' => $coment->id, 'user' => $coment->user, 'message' => $coment->message, 'answer' => $coment->answer];
         }
         return $data;
     });
 }
开发者ID:panfillich,项目名称:myblog,代码行数:12,代码来源:Comments.php

示例5: register

 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     $config = (new GeoCode\Config())->initFromArray(config('services.geo_code'));
     $this->app->singleton(GeoCode\Manager::class, function ($app) use($config) {
         $req = new GeoCode\Http\Guzzle(['base_uri' => $config->apiUrl, 'verify' => false]);
         return new GeoCode\Manager($config, $req, Cache::store($config->cacheDriver));
     });
     $this->app->bind(GeoCode\Response::class, function ($app) use($config) {
         return new GeoCode\Response($config->apiOutput, '');
     });
     $this->app->instance(GeoCode\Config::class, $config);
 }
开发者ID:domencom,项目名称:laravel,代码行数:17,代码来源:GeoCodeServiceProvider.php

示例6: index

 public function index()
 {
     $navFlag = 'blog';
     $newPosts = Cache::store('redis')->remember($this->indexPostsKey, 30, function () {
         $articles = [];
         $list = Wp::type('post')->status('publish')->orderBy('post_date', 'desc')->take(17)->get();
         foreach ($list as $item) {
             $articles[] = ['url' => $item->url, 'post_title' => $item->post_title, 'post_date' => $item->post_date->format('Y-m-d')];
         }
         return $articles;
     });
     return View('index/blog', compact('newPosts', 'navFlag'));
 }
开发者ID:tanteng,项目名称:tanteng.me,代码行数:13,代码来源:BlogController.php

示例7: getAll

 public function getAll()
 {
     return Cache::store('prevAll')->rememberForever($this->page, function () {
         //методанные
         $items['title'] = 'Главная';
         $items['keywords'] = 'блог, разработка, php, главная';
         $items['description'] = 'Главная страница блога начинающего backend разработчика. Заходите.';
         //превьюхи
         $articles = new Articles();
         $articles = $articles->published()->orderByParam()->with('tags', 'category')->paginate($this->countPage);
         //Превьюхи в нужном формате
         $items['articles'] = $this->createArrPreviews($articles);
         return $this->createLengthAwarePaginator($articles, $items);
     });
 }
开发者ID:panfillich,项目名称:myblog,代码行数:15,代码来源:Previews.php

示例8: getCategoryNavigate

 public function getCategoryNavigate()
 {
     return Cache::store($this->store)->rememberForever('menu:cat', function () {
         $cat_cl = new Categories();
         $categories = $cat_cl->getAllCategory();
         foreach ($categories as $key => $category) {
             $date[$key]['id'] = $category->id;
             $date[$key]['name'] = $category->name;
             $date[$key]['curl'] = $category->curl;
             //Получаем кол-во новостей в каждой категории
             $date[$key]['count_article'] = $category->getArticlesByCondition()->count();
         }
         return $date;
     });
 }
开发者ID:panfillich,项目名称:myblog,代码行数:15,代码来源:Aside.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $blockIps = Cache::get('block_ip', function () {
         $blockIps = BlockIp::all()->toArray();
         Cache::store('redis')->put('block_ip', $blockIps, 10);
         return $blockIps;
     });
     if ($blockIps) {
         foreach ($blockIps as $ip) {
             if (starts_with($request->getClientIp(), $ip['ip_address'])) {
                 abort(404);
             }
         }
     }
     return $next($request);
 }
开发者ID:picolit,项目名称:bbs,代码行数:23,代码来源:BlockAccess.php

示例10: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     Cache::store('aside')->flush();
     $this->info('Asides cleared');
     Cache::store('prevAll')->flush();
     $this->info('Prev. cleared');
     Cache::store('prevCat')->flush();
     $this->info('Prev./cat. cleared');
     Cache::store('prevTag')->flush();
     $this->info('Prev./tag. cleared');
     Cache::store('article')->flush();
     $this->info('Articles cleared');
     Cache::store('comments')->flush();
     $this->info('Comments cleared');
     $this->info('All automatic cache cleared');
 }
开发者ID:panfillich,项目名称:myblog,代码行数:21,代码来源:ClearCache.php

示例11: gitCommitHistory

 /**
  * Github上提交版本历史
  * @method POST
  * @return string
  */
 public function gitCommitHistory()
 {
     $client = new Client(['base_uri' => 'https://api.github.com/']);
     $uri = 'repos/tanteng/tanteng.me/commits';
     $query['client_id'] = Config::get('github.client_id');
     $query['client_secret'] = Config::get('github.client_secret');
     try {
         $result = Cache::store('redis')->remember('git.commit.history', 60, function () use($client, $uri, $query) {
             return $client->get($uri, $query)->getBody()->getContents();
         });
     } catch (ConnectException $e) {
         return json_encode(['result' => 1001, 'msg' => '请求超时!', 'data' => $e->getMessage()]);
     }
     $result = json_decode($result, true);
     $commitHistory = [];
     foreach ($result as $item) {
         $commitHistory[] = ['message' => $item['commit']['message'], 'datetime' => date('Y-m-d H:i:s', strtotime($item['commit']['committer']['date']))];
     }
     return json_encode(['result' => 0, 'msg' => '请求成功!', 'data' => $commitHistory]);
 }
开发者ID:tanteng,项目名称:tanteng.me,代码行数:25,代码来源:IndexController.php

示例12: __construct

 /**
  * Assign dependencies.
  */
 public function __construct()
 {
     $this->cache = Cache::store();
 }
开发者ID:spira,项目名称:api-core,代码行数:7,代码来源:Dataset.php

示例13: flushCache

 public function flushCache($store)
 {
     Cache::store($store)->flush();
 }
开发者ID:gabwhite,项目名称:fsh,代码行数:4,代码来源:CacheManager.php


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