Reuse.Cache.Net
1.0.0
dotnet add package Reuse.Cache.Net --version 1.0.0
NuGet\Install-Package Reuse.Cache.Net -Version 1.0.0
<PackageReference Include="Reuse.Cache.Net" Version="1.0.0" />
<PackageVersion Include="Reuse.Cache.Net" Version="1.0.0" />
<PackageReference Include="Reuse.Cache.Net" />
paket add Reuse.Cache.Net --version 1.0.0
#r "nuget: Reuse.Cache.Net, 1.0.0"
#:package Reuse.Cache.Net@1.0.0
#addin nuget:?package=Reuse.Cache.Net&version=1.0.0
#tool nuget:?package=Reuse.Cache.Net&version=1.0.0
RedisCacheMiddleware - .NET Core 通用缓存中间件
一个基于 NewLife.Redis 实现的可复用缓存中间件,包含管理页面,让你无需在每个项目中重复开发缓存功能。
功能特点
开箱即用:简单配置即可集成到任何 .NET Core 项目
强大缓存能力:基于 NewLife.Redis 实现,支持多种缓存策略
可视化管理:内置 Web 管理界面,轻松查看 / 删除缓存项
灵活配置:支持自定义缓存过期时间、前缀等参数
中间件模式:通过管道拦截请求,自动处理缓存逻辑
可扩展性:预留扩展点,方便根据业务需求定制功能
技术栈
.NET Core 3.1+ / .NET 5+ / .NET 6+ / .NET 7+ / .NET 8+
NewLife.Redis 5.0+
ASP.NET Core MVC
vue3 & tdesign组件 & tailwindcss (管理页面)
安装方式
1. 通过 NuGet 安装(没有nuget包,此步骤忽略)
Install-Package xxx
\# 或使用 .NET CLI
dotnet add package xxx
2. 手动引用
下载源码编译生成 DLL,添加到项目引用中。
快速开始
1. 配置 Redis 连接字符串(具体请看项目中的cache.json)
在 appsettings.json 中添加:
"Cache": {
}
2. 在 Startup.cs 或 Program.cs 中注册服务
对于 .NET 6+ 最小 API 模式 (Program.cs):
var builder = WebApplication.CreateBuilder(args);
// 添加缓存中间件服务
builder.Services.AddCache();
var app = builder.Build();
// 获取缓存服务
1. 构造函数获取缓存服务
...
2. 通过依赖注入获取缓存服务
var _cacheService = app.Services.GetRequiredService<CacheService>();
// 启用管理页面(默认路径:/cacheUI)
app.UseCacheManagerUI('/cacheUI');
app.Run();
4. 访问管理页面
启动项目后,访问 http://yourdomain/cacheUI 即可打开管理页面,在这里你可以:
查看所有缓存键列表
查看缓存项的详细信息(值、过期时间等)
手动删除指定缓存项
清空所有缓存
配置说明
| 配置项 | 说明 | 默认值 |
|---|---|---|
| Redis 连接字符串 | 127.0.0.1:6379 | |
| DbIndex | Redis 数据库索引 | 0 |
| KeyPrefix | 缓存键前缀,用于区分不同应用 | 空 |
| DefaultExpireSeconds | 默认过期时间(秒) | 3600 |
| AdminPath | 管理页面路径 | /cache-admin |
| EnableAdmin | 是否启用管理页面 | true |
| EnableLogging | 是否启用缓存操作日志 | false |
管理页面预览
管理页面包含以下功能区域:
缓存统计:显示缓存总数、内存占用等信息
缓存列表:分页展示所有缓存键,支持搜索和筛选
缓存详情:查看选中缓存项的完整信息
操作区:提供删除、清空等操作按钮
注意事项
确保 Redis 服务已启动并能被应用访问
对于敏感数据,建议在缓存前进行加密处理
管理页面默认没有权限控制,生产环境中建议添加身份验证
// 添加权限控制示例
版本历史
v1.0.0:初始版本,包含基本缓存功能和管理页面
v1.1.0:添加自定义缓存策略支持,优化管理页面 UI
v1.2.0:增加缓存操作日志,修复已知 bug
贡献指南
Fork 本仓库
创建特性分支 (
git checkout -b feature/amazing-feature)提交更改 (
git commit -m 'Add some amazing feature')推送到分支 (
git push origin feature/amazing-feature)打开 Pull Request
许可证
本项目采用 MIT 许可证 - 详见 LICENSE 文件。
联系方式
如有问题或建议,请提交 Issue 或联系:
作者:Your Name
邮箱:your.email@example.com
让缓存管理变得简单,专注于你的业务逻辑而非重复造轮子!🚀
(注:文档部分内容可能由 AI 生成)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.StaticFiles (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.Extensions.FileProviders.Embedded (>= 9.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.1)
- Microsoft.Extensions.Options (>= 6.0.1)
- NewLife.Redis (>= 6.3.2025.701)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 162 | 7/30/2025 |