kyrenator/query-cache
最新稳定版本:v1.0.1
Composer 安装命令:
composer require kyrenator/query-cache
包简介
Easily Cache Eloquent Collections
README 文档
README
IMPORTANT NOTICE: This package is not maintained and maybe not working at all. Use it at your own risk!!
Laravel 5 query cache
This Laravel 5 package allows you to easily cache eloquent queries by implementing laravel 4 remember method.
##How to use ###Step 1: Install Through Composer
composer require kyrenator/query-cache
###Step 2: Use QueryCache In Your Model
<?php namespace App; use Kyrenator\QueryCache\QueryCache; use Illuminate\Database\Eloquent\Model; class Post extends Model { use QueryCache; }
###Step 3: Use remember Method When Quering Eloquent When calling remember method you can tell it for how many minutes you want the query be cached. If you dont specify the minutes, the query will be cached for 60 minutes.
\App\Post::remember()->take(3)->get(); //use cache tags \App\Post::remember()->cacheTags('posts', 'fresh')->take(3)->get();
##More Features ###Global Cache If you want you can cache all queries for a specific model by siply defining cacheAll var inside your model. QueryCache will aply remember method to all model queries.
<?php namespace App; use Kyrenator\QueryCache\QueryCache; use Illuminate\Database\Eloquent\Model; class Post extends Model { use QueryCache; protected $cacheAll = true; }
###Clear Cache On Change If you want the cache to be flushed when you create, delete, or update an existing model then define $clearOnChange
<?php namespace App; use Kyrenator\QueryCache\QueryCache; use Illuminate\Database\Eloquent\Model; class Post extends Model { use QueryCache; protected $clearOnChange = true; }
###Cache Tags QueryCache will use the model name as cache tags. You can also define custon cache tags.
<?php namespace App; use Kyrenator\QueryCache\QueryCache; use Illuminate\Database\Eloquent\Model; class Post extends Model { use QueryCache; protected $clearOnChange = true; protected $cacheTags = 'fresh'; protected $cacheAll = true; }
统计信息
- 总下载量: 219
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-27