litermi / cache-query-builder
这是一个从查询生成和在使用特定方法时清除缓存的包提供程序
1.0.49
2024-09-13 14:21 UTC
Requires
- php: ^7.4|^8.0
- illuminate/config: ^6.9|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/console: ^6.9|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/contracts: ^6.9|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/database: ^6.9|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/http: ^6.9|^7.0|^8.0|^9.0|^10.0|^11.0
- kirschbaum-development/eloquent-power-joins: ^2.5|^2.6|^3.5
- litermi/logs: ^1.0
- spatie/laravel-query-builder: ^3.6|^5.0|^5.8
- dev-main
- 1.0.49
- 1.0.48
- 1.0.47
- 1.0.46
- 1.0.45
- 1.0.44
- 1.0.43
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- dev-feature/BAC-67-add-create-method-to-purge-cache-before-active-record-trait
This package is auto-updated.
Last update: 2024-09-13 14:21:37 UTC
README
关于
cache-query-builder
包允许您提高性能并降低数据库请求的压力。
如何创建 composer 包的教程
功能
- 缓存查询获取列和值
- 缓存子查询/关系
- 根据模型设置时间
- 从缓存获取和获取第一个值的方法
- 保存、插入、删除到缓存的方法
安装
在您的 composer.json
中添加 litermi/cache-query-builder
包并更新依赖关系
composer require litermi/cache-query-builder
配置
设置提供者
'providers' => [ // ... Litermi\Cache\Providers\ServiceProvider::class, ],
默认设置在 config/cache-query.php
中。发布配置以复制文件到您自己的配置
php artisan vendor:publish --provider="Litermi\Cache\Providers\ServiceProvider"
注意:这是必要的,以便您可以更改默认配置
使用方法
要缓存查询,您需要使用扩展类
class Product extends CacheModel { }
要缓存查询,您需要使用方法:getFromCache 或 firstCache
return Product::query() ->where('active', ModelConst::ENABLED) ->with($relations) ->getFromCache(['*'], $tags);
如果您想清除缓存,可以使用方法:saveWithCache、insertWithCache、deleteWithCache
$product = new Product(); $product->saveWithCache();
Product::insertWithCache($values);
$product->deleteWithCache();
许可证
在 MIT 许可证下发布,请参阅 LICENSE。