\W7\Laravel\CacheModel\Caches\Cache::setCacheResolver(Cache::store());
use W7\Laravel\CacheModel\Model;
class Member extends Model
{
public $timestamps = false;
protected $table = 'members';
protected $primaryKey = 'uid';
// 此行可缺省
protected $useCache = true;
}
$uid = 1;
$user = Member::query()->find($uid);
$user = Member::query()->find($uid);
// query once
// select * from `ims_members` where `ims_members`.`uid` = ? limit 1
仅限指定 id 查询,不限定返回列。
$uids = [1, 2, 5];
Member::query()->find($uids);
Member::query()->find($uids);
// query once
// select * from `ims_members` where `ims_members`.`uid` in (?, ?, ?)
删除缓存。
$member = Member::find($uid)
$member->invite_code = rand(1, 100000);
$member->save();
删除缓存
删除缓存
清空指定表的缓存