msolutions / tag-cache
文件标签缓存包
0.9.4
2024-08-21 06:27 UTC
Requires
- php: ^7.4|^8.0|^8.1|^8.2|^8.3
- illuminate/filesystem: ^8.0|^9.0|^10.0|^11.0
This package is not auto-updated.
Last update: 2024-10-02 07:07:58 UTC
README
版本 0.9.4
此库是为了满足标签缓存系统的需求而构建的
特性
- 以组织的方式存储缓存数据
- 自动缓存过期
- 减少SQL查询请求
安装
composer require msolutions/tag-cache
实现
use MSL\TagCache;
//caching query or any other data
$unique_key = "unique-name";
$ttl = (60*60);//timing for expiry in seconds
$result = TagCache::remember($unique_key, $ttl, function() {
//database query fetching should be inside this function
$cache_data = Model::get(); //database fetch query
return $cache_data;
}, ["tag1", "tag2"]);
移除缓存
$unique_key = "unique-name"; //you cache unique key
TagCache::flush_cache(["tag1", "tag2"], $unique_key);
移除所有缓存
TagCache::flush_all();
此开源包是通用开发的,任何开发者都可以免费使用。
- 请分享您的评论和想法,以改进此包。