8
Laravel 的 ORM 缓存包
source link: https://blog.p2hp.com/archives/8821
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Laravel 的 ORM 缓存包
LaraCache是一个基于 ORM 的 Laravel 包,用于基于模型查询创建、更新和管理缓存项。使用此包,您可以缓存在整个应用程序中大量使用的查询。
use Mostafaznv\LaraCache\Traits\LaraCache;
class Article extends Model
use LaraCache;
public static function cacheEntities(): array
return [
CacheEntity::make('list.forever')
->cache(function() {
return Article::query()->latest()->get();
CacheEntity::make('latest')
->validForRestOfDay()
->cache(function() {
return Article::query()->latest()->first();
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK