mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-03-24 20:27:21 +08:00
【新增】新增【EasyCaching.CSRedis】redis组件,替换SqlSugar二级缓存的【StackExchange.Redis】组件实现,使用异步替代同步处理二级缓存,解决【StackExchange.Redis】超过200并发后的异常情况。异步提升二级缓存获取效率。
【新增】appsetting.json配置文件增加【AppPcUrl】PC端访问地址,【AppH5Url】H5端访问地址,方便对接pc端、h5端、微信公众号端。
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.Redis;
|
||||
using StackExchange.Redis;
|
||||
using CoreCms.Net.Configuration;
|
||||
|
||||
namespace CoreCms.Net.Caching.SqlSugar
|
||||
{
|
||||
public class SqlSugarRedisCache : ICacheService
|
||||
{
|
||||
//readonly RedisCacheManager _service = null;
|
||||
|
||||
static readonly RedisCacheManager _service = new RedisCacheManager();
|
||||
|
||||
public SqlSugarRedisCache()
|
||||
{
|
||||
//_service = new RedisCacheManager(); ;
|
||||
}
|
||||
|
||||
public void Add<TV>(string key, TV value)
|
||||
{
|
||||
_service.Set(key, value);
|
||||
}
|
||||
|
||||
public void Add<TV>(string key, TV value, int cacheDurationInSeconds)
|
||||
{
|
||||
_service.Set(key, value, cacheDurationInSeconds);
|
||||
}
|
||||
|
||||
public bool ContainsKey<TV>(string key)
|
||||
{
|
||||
return _service.Exists(key);
|
||||
}
|
||||
|
||||
public TV Get<TV>(string key)
|
||||
{
|
||||
return _service.Get<TV>(key);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllKey<TV>()
|
||||
{
|
||||
|
||||
return _service.SearchCacheRegex("SqlSugarDataCache.*");
|
||||
}
|
||||
|
||||
public TV GetOrCreate<TV>(string cacheKey, Func<TV> create, int cacheDurationInSeconds = int.MaxValue)
|
||||
{
|
||||
if (this.ContainsKey<TV>(cacheKey))
|
||||
{
|
||||
return this.Get<TV>(cacheKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = create();
|
||||
this.Add(cacheKey, result, cacheDurationInSeconds);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove<TV>(string key)
|
||||
{
|
||||
_service.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user