doxroot/laravel-redis-cache
最新稳定版本:0.0.3
Composer 安装命令:
composer require doxroot/laravel-redis-cache
包简介
A simple way to cache things in Laravel framework using "tags"
README 文档
README
composer require doxroot/laravel-redis-cache
Purpose
This library uses Laravel, but with a different approach to tags. It's mutch to say tags, as it uses the default Laravel cache system to create just a wrapper and nothing more around a powerful cache from the default Laravel core system.
What I don't like about tags in Laravel is the default mechanism. Each key stored in a tag has to be added to another list for later cleanup.
Well, in most applications, a simpler solution might be better.
This application will create a key like: tag:filter:key In Redis, we can simply remove all keys that start with some_path*. And that's it. Nothing more with this library.
I am making this available in the hope that it can help someone.
Some additional info
Just extend AbstractRedisCache for other needs. Very simple. Hard to say a library, because it's just an absolute minimal wrapper arounde Cache facade.
DoxrootDbQueryRedisCache::put(key1, value);
DoxrootDbQueryRedisCache::put(key2, value);
Add 2 keys
DoxrootDbQueryRedisCache::put(key3, value, filterKey: test);
DoxrootDbQueryRedisCache::put(key4, value, filterKey: test);
DoxrootDbQueryRedisCache::put(key5, value, filterKey: test1);
DoxrootDbQueryRedisCache::put(key6, value, filterKey: test1);
Add 4 more keys (total 6)
DoxrootDbQueryRedisCache::flush(); // will remove all 6 keys
DoxrootDbQueryRedisCache::flush(test); will remove only key3 && key4
DoxrootDbQueryRedisCache::flush(test1); will remove only key5 && key6
So, just a minimal wrapper for cache.
Some benchmark results:
Code used for Laravel:
Cache:tags([tag-name])->put(key, value);
Cache::tags([tag-name])->flush();
Code using this library:
DoxrootDbQueryRedisCache::put(key, value);
DoxrootDbQueryRedisCache::flush();
Results
Insert 100K rows using Laravel Time: 36.89 seconds
Insert 100K rows using this lib Time: 19.95 seconds
Insert 1M rows using Laravel Time: 373.27 seconds || 6.23 minutes
Insert 1M rows using this lib Time: 203.28 seconds || 3.38 minutes
Remove all data (1M rows) Laravel Time: 5.64 seconds
Remove all data (1M rows) using this lib Time: 1.63 seconds
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-07