Files
shgx_tz_mes_backend_sync/server/ZR.Admin.WebApi/Extensions/SqlSugarCache.cs
赵正易 ceeef502ba Merge branch 'main' of https://gitee.com/doan-tech/shanghaigangxiangtuzhuangMES
# Conflicts:
#	server/ZR.Admin.WebApi/Controllers/mes/qc/FQC/CommonFQCController.cs
#	server/ZR.Admin.WebApi/Extensions/SqlSugarCache.cs
#	server/ZR.Model/MES/qc/DTO/QcCommonFqcDto.cs
#	server/ZR.Service/mes/qc/CommonFQCService.cs
#	server/ZR.Service/mes/qc/IService/ICommonFQCService.cs
2024-06-07 11:26:31 +08:00

132 lines
3.7 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<<<<<<< HEAD:ZR.Admin.WebApi/Extensions/SqlSugarCache.cs
namespace ZR.Admin.WebApi.Extensions
{
public class SqlSugarCache : SqlSugar.ICacheService
{
public void Add<V>(string key, V value)
{
//RedisServer.Cache.Set(key, value, 3600 + RedisHelper.RandomExpired(5, 30));
CacheHelper.SetCache(key, value);
}
public void Add<V>(string key, V value, int cacheDurationInSeconds)
{
//RedisServer.Cache.Set(key, value, cacheDurationInSeconds);
CacheHelper.SetCaches(key, value, cacheDurationInSeconds);
}
public bool ContainsKey<V>(string key)
{
//return RedisServer.Cache.Exists(key);
return CacheHelper.Exists(key);
}
public V Get<V>(string key)
{
//return RedisServer.Cache.Get<V>(key);
return (V)CacheHelper.Get(key);
}
public IEnumerable<string> GetAllKey<V>()
{
//return RedisServer.Cache.Keys("*");
return CacheHelper.GetCacheKeys();
}
public V GetOrCreate<V>(string cacheKey, Func<V> create, int cacheDurationInSeconds = int.MaxValue)
{
if (ContainsKey<V>(cacheKey))
{
var result = Get<V>(cacheKey);
if (result == null)
{
return create();
}
else
{
return result;
}
}
else
{
var restul = create();
Add(cacheKey, restul, cacheDurationInSeconds);
return restul;
}
}
public void Remove<V>(string key)
{
//RedisServer.Cache.Del(key);
CacheHelper.Remove(key);
}
}
=======
using ZR.Common;
namespace ZR.Admin.WebApi.Extensions
{
public class SqlSugarCache : SqlSugar.ICacheService
{
public void Add<V>(string key, V value)
{
//RedisServer.Cache.Set(key, value, 3600 + RedisHelper.RandomExpired(5, 30));
CacheHelper.SetCache(key, value);
}
public void Add<V>(string key, V value, int cacheDurationInSeconds)
{
//RedisServer.Cache.Set(key, value, cacheDurationInSeconds);
CacheHelper.SetCaches(key, value, cacheDurationInSeconds);
}
public bool ContainsKey<V>(string key)
{
//return RedisServer.Cache.Exists(key);
return CacheHelper.Exists(key);
}
public V Get<V>(string key)
{
//return RedisServer.Cache.Get<V>(key);
return (V)CacheHelper.Get(key);
}
public IEnumerable<string> GetAllKey<V>()
{
//return RedisServer.Cache.Keys("*");
return CacheHelper.GetCacheKeys();
}
public V GetOrCreate<V>(string cacheKey, Func<V> create, int cacheDurationInSeconds = int.MaxValue)
{
if (ContainsKey<V>(cacheKey))
{
var result = Get<V>(cacheKey);
if (result == null)
{
return create();
}
else
{
return result;
}
}
else
{
var restul = create();
Add(cacheKey, restul, cacheDurationInSeconds);
return restul;
}
}
public void Remove<V>(string key)
{
//RedisServer.Cache.Del(key);
CacheHelper.Remove(key);
}
}
>>>>>>> 80b1bbccf9a33424c3a3126c05ea829a35a78c2c:server/ZR.Admin.WebApi/Extensions/SqlSugarCache.cs
}