修改:Redis方法修改。

This commit is contained in:
2025-12-22 17:47:19 +08:00
parent 67f9192182
commit aa0d7043bf
11 changed files with 237 additions and 85 deletions

View File

@@ -9,14 +9,14 @@ public abstract class BaseCacheHelpRedis
{
public static T GetCache<T>(string key, Func<T> setAcrion, TimeSpan? expiry = null)
{
if (RedisHelper.CheckKey(key))
if (StackChangeRedisHelper.CheckKey(key))
{
return RedisHelper.StringGet<T>(key);
return StackChangeRedisHelper.StringGet<T>(key);
}
T val = setAcrion();
if (val != null)
{
RedisHelper.StringSet(key, val, expiry);
StackChangeRedisHelper.StringSet(key, val, expiry);
}
return val;
}
@@ -26,62 +26,62 @@ public abstract class BaseCacheHelpRedis
T val = setAcrion();
if (val != null)
{
RedisHelper.StringSet(key, val, expiry);
StackChangeRedisHelper.StringSet(key, val, expiry);
}
}
public static T GetVaue<T>(string key)
{
if (RedisHelper.CheckKey(key))
if (StackChangeRedisHelper.CheckKey(key))
{
return RedisHelper.StringGet<T>(key);
return StackChangeRedisHelper.StringGet<T>(key);
}
return default(T);
}
public static void ClearCache(string key)
{
if (RedisHelper.CheckKey(key))
if (StackChangeRedisHelper.CheckKey(key))
{
RedisHelper.RemoveKey(key);
StackChangeRedisHelper.RemoveKey(key);
}
}
public static void ClearCacheList(List<string> keyList)
{
RedisHelper.RemoveKeyList(keyList);
StackChangeRedisHelper.RemoveKeyList(keyList);
}
public static T GetHashCache<T>(string key, string sid, Func<T> setAcrion)
{
if (RedisHelper.HashExists(key, sid))
if (StackChangeRedisHelper.HashExists(key, sid))
{
return RedisHelper.HashGet<T>(key, sid);
return StackChangeRedisHelper.HashGet<T>(key, sid);
}
T val = setAcrion();
if (val != null)
{
RedisHelper.HashSet(key, sid, val);
StackChangeRedisHelper.HashSet(key, sid, val);
}
return val;
}
public static void SetHashCache<T>(string key, string sid, T model)
{
RedisHelper.HashSet(key, sid, model);
StackChangeRedisHelper.HashSet(key, sid, model);
}
public static void SetHashCache<T>(string key, Dictionary<string, T> dic)
{
RedisHelper.HashSet(key, dic);
StackChangeRedisHelper.HashSet(key, dic);
}
public static Dictionary<string, T> GetHashAllCache<T>(string key)
{
return RedisHelper.HashGetAll<T>(key);
return StackChangeRedisHelper.HashGetAll<T>(key);
}
public static bool CheckKey(string key)
{
return RedisHelper.CheckKey(key);
return StackChangeRedisHelper.CheckKey(key);
}
}

View File

@@ -173,7 +173,7 @@ namespace Services.Tool
/// <summary>
/// redis 数据库操作帮助类
/// </summary>
public class RedisHelper
public class StackChangeRedisHelper
{
//执行顺序---静态字段---静态构造函数---构造函数