You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.5 KiB
1.5 KiB
LINGYUN.Abp.CachingManagement.StackExchangeRedis
基于 StackExchange.Redis 的缓存管理实现模块。
功能
- 实现了
ICacheManager接口,提供基于 Redis 的缓存管理功能:- 获取缓存键列表(支持前缀匹配和过滤)
- 获取缓存值
- 设置缓存值(支持绝对过期时间和滑动过期时间)
- 刷新缓存
- 删除缓存
安装
abp add-module LINGYUN.Abp.CachingManagement
配置使用
- 首先需要配置 Redis 连接字符串,在
appsettings.json中添加:
{
"Redis": {
"Configuration": "127.0.0.1:6379"
}
}
- 在模块的
ConfigureServices方法中添加以下代码:
Configure<RedisCacheOptions>(options =>
{
// 可选:配置 Redis 实例名称前缀
options.InstanceName = "MyApp:";
});
Configure<AbpDistributedCacheOptions>(options =>
{
// 可选:配置缓存键前缀
options.KeyPrefix = "MyApp:";
});
多租户支持
模块内置了多租户支持,会自动根据当前租户ID来隔离缓存数据:
- 有租户时的键格式:
{InstanceName}t:{TenantId}:{KeyPrefix}:{Key} - 无租户时的键格式:
{InstanceName}c:{KeyPrefix}:{Key}
更多
有关更多信息,请参阅以下资源: