承接 singlequote/laravel-cacher 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Version on Packagist Total Downloads

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.

统计信息

  • 总下载量: 25.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固