singlequote/laravel-cacher
Composer 安装命令:
composer require singlequote/laravel-cacher
包简介
A powerfull cacher based on laravels file cache driver
README 文档
README
A powerful cache trait based on Laravel's file cache driver
Installation
composer require singlequote/laravel-cacher
Usage
Model Caching
Sometimes you just want to cache Eloquent Model results. With Model caching you can, without making a mess in your code. Just include the cacher trait within your model:
namespace App; use Illuminate\Foundation\Auth\User as Authenticatable; //<= basic shizzle use Illuminate\Contracts\Auth\MustVerifyEmail; //<= basic shizzle use SingleQuote\Cacher\Traits\Cacher; //⇐ this one class User extends Authenticatable implements MustVerifyEmail { use Cacher; //<= require the model to use the trait }
Now whenever you call your App\User model, you can use the caching trait
use App\User; $users = User::whereEmail('foo@bar.world')->remember(); //<= default ttl is 7 days $users = User::whereEmail('foo@bar.world')->remember(3600); //<= 1 hour //or keep it forever by your side <3 $users = User::whereEmail('foo@bar.world')->rememberForever();
Custom prefix
By default the cache prefix is unique. You can use your own prefix by calling the prefix method
$users = User::whereEmail('foo@bar.world')->prefix("all-users")->remember(); //prefix all-users cache()->forget("all-users");
All methods
$users = User::whereEmail('foo@bar.world')->remember(/*3600*/); //for 1 hour - default 7 days $users = User::whereEmail('foo@bar.world')->rememberForever(); //for ever //find $user = User::whereEmail('foo@bar.world')->findAndRemember(1, /*3600*/); $user = User::whereEmail('foo@bar.world')->findAndRememberForever(1); //first $user = User::whereEmail('foo@bar.world')->firstAndRemember(/*3600*/); $user = User::whereEmail('foo@bar.world')->firstAndRememberForever(); //counting $user = User::whereEmail('foo@bar.world')->rememberCount(/*3600*/); $user = User::whereEmail('foo@bar.world')->rememberCountForever(); //paginating $user = User::whereEmail('foo@bar.world')->paginateAndRemember(20, /*3600*/); //return 20 results $user = User::whereEmail('foo@bar.world')->paginateAndRememberForever(20); //return 20 results
Contributing
Please see CONTRIBUTING for details.
Postcardware
You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Quotec, Traktieweg 8c 8304 BA, Emmeloord, Netherlands.
Credits
License
The MIT License (MIT). Please see License File for more information.
singlequote/laravel-cacher 适用场景与选型建议
singlequote/laravel-cacher 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25.22k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 09 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cache」 「tags」 「laravel」 「cacher」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 singlequote/laravel-cacher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 singlequote/laravel-cacher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 singlequote/laravel-cacher 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Phalcon PHP Meta tags service
A tool for scraping URL resources (oEmbed, OpenGraph, Twitter cards, JSON-LD)
The tag extension for the yii framework
Colorizes the Flarum forum header and interface based on the active tag's color.
Laravel 5 - Repositories to the database layer
统计信息
- 总下载量: 25.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-06