3 Star 3 Fork 0

微擎 / 模型缓存

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

w7Laravel

使用说明

1. 注册 Psr\SimpleCache\CacheInterface 实现

\W7\Laravel\CacheModel\Caches\Cache::setCacheResolver(Cache::store());

2. 继承 W7\Laravel\CacheModel\Model

use W7\Laravel\CacheModel\Model;

class Member extends Model
{
	public $timestamps = false;
	
	protected $table = 'members';
	
	protected $primaryKey = 'uid';

    // 此行可缺省 
	protected $useCache = true;
}

3. 使用

find($id)

$uid  = 1;
$user = Member::query()->find($uid);
$user = Member::query()->find($uid);

// query once
// select * from `ims_members` where `ims_members`.`uid` = ? limit 1

find($ids)

仅限指定 id 查询,不限定返回列。

$uids = [1, 2, 5];
Member::query()->find($uids);
Member::query()->find($uids);

// query once
// select * from `ims_members` where `ims_members`.`uid` in (?, ?, ?)

$model->save();

删除缓存。

$member = Member::find($uid)
$member->invite_code = rand(1, 100000);
$member->save();

$model->update();

删除缓存

$model->delete();

删除缓存

Member::flush();

清空指定表的缓存

Cache::flush();

Comments ( 0 )

Sign in for post a comment

About

Laravel/Model find、findMany 支持缓存 spread retract
Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more
1
https://gitee.com/we7coreteam/w7-laravel-cache-model.git
git@gitee.com:we7coreteam/w7-laravel-cache-model.git
we7coreteam
w7-laravel-cache-model
模型缓存
master

Search