当前位置:网站首页>ORM cache package for laravel
ORM cache package for laravel
2022-06-27 02:15:00 【lenixa】
Laravel Of ORM Cache package
LaraCache It's based on ORM Of Laravel package , Used to create... Based on model queries 、 Update and manage cache entries . Use this package , You can cache queries that are heavily used throughout your application .
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();
})
];
}
} Use this cacheEntities Method to define a cache query ,Laracache Will be responsible for the rest of the work . To use cached queries , You will invoke the model , As shown in the following example :
use Mostafaznv\LaraCache\Facades\LaraCache;
$cache = Article::cache()->get('latest');
// or
$cache = LaraCache::retrieve(Article::class, 'latest');Use this package , You can use the following functions to control the cache :
- Enable / Disable caching
- Manually update cache
- Manually update all cached entities
- Delete cache
CacheEntityUse fluent methods orttl()Method control duration
I think the following manual cache update method is simple , The cache can be refreshed immediately :
Article::cache()->update('latest');
// or
LaraCache::update(Article::class, 'latest');You can learn about this bag , Get complete installation instructions , And in GitHub Check out Source code .
边栏推荐
- Oracle/PLSQL: Rpad Function
- Some exception handling for idea plug-in development
- C language -- Design of employee information management system
- Why divide the training set and the test set before normalization?
- Oracle/PLSQL: Translate Function
- C# Tcp服务器如何限制同一个IP的连接数量?
- three.js多米诺骨牌js特效
- lottie.js创意开关按钮动物头像
- paddlepaddle 20 指数移动平均(ExponentialMovingAverage,EMA)的实现与使用(支持静态图与动态图)
- Sample development of WiFi IOT Hongmeng development kit
猜你喜欢

mmdetection ValueError: need at least one array to concatenate解决方案

热议:月薪1.8万却毫无意义的工作,你干吗?

SQLite reader plug-in tests SQLite syntax

Some exception handling for idea plug-in development

解决cherry pick提交报错问题

TechSmith Camtasia最新2022版详细功能讲解下载

lottie.js创意开关按钮动物头像

C语言--职工信息管理系统设计

H5 liquid animation JS special effect code

使用命令行安装达梦数据库
随机推荐
paddlepaddle 21 基于dropout实现用4行代码dropblock
Consumers pursue the iPhone because its cost performance exceeds that of domestic mobile phones
SQLite reader plug-in tests SQLite syntax
Flink学习5:工作原理
参数估计——《概率论及其数理统计》第七章学习报告(点估计)
mmdetection 用yolox训练自己的coco数据集
Oracle/PLSQL: Length Function
Flink learning 5: how it works
Don't be brainwashed. This is the truth about the wages of 90% of Chinese people
Why divide the training set and the test set before normalization?
Oracle/PLSQL: NumToYMInterval Function
达梦数据库安装
C语言--职工信息管理系统设计
正则表达式:语法
别被洗脑了,这才是90%中国人的工资真相
解决cherry pick提交报错问题
Google began to roll itself, AI architecture pathways was blessed, and 20billion generation models were launched
Flink Learning 2: Application Scenarios
Oracle/PLSQL: To_Clob Function
Svg drag dress Kitty Cat