初始化项目

This commit is contained in:
2025-11-20 09:50:21 +08:00
commit 94b24e1a5d
4209 changed files with 1570805 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
// Services.Cache.BaseCacheHelpRedis
using System;
using System.Collections.Generic;
using Org.BouncyCastle.Utilities;
using Services.Tool;
using StackExchange.Redis;
public abstract class BaseCacheHelpRedis
{
public static T GetCache<T>(string key, Func<T> setAcrion, TimeSpan? expiry = null)
{
if (RedisHelper.CheckKey(key))
{
return RedisHelper.StringGet<T>(key);
}
T val = setAcrion();
if (val != null)
{
RedisHelper.StringSet(key, val, expiry);
}
return val;
}
public static void SetCache<T>(string key, Func<T> setAcrion, TimeSpan? expiry = null)
{
T val = setAcrion();
if (val != null)
{
RedisHelper.StringSet(key, val, expiry);
}
}
public static T GetVaue<T>(string key)
{
if (RedisHelper.CheckKey(key))
{
return RedisHelper.StringGet<T>(key);
}
return default(T);
}
public static void ClearCache(string key)
{
if (RedisHelper.CheckKey(key))
{
RedisHelper.RemoveKey(key);
}
}
public static void ClearCacheList(List<string> keyList)
{
RedisHelper.RemoveKeyList(keyList);
}
public static T GetHashCache<T>(string key, string sid, Func<T> setAcrion)
{
if (RedisHelper.HashExists(key, sid))
{
return RedisHelper.HashGet<T>(key, sid);
}
T val = setAcrion();
if (val != null)
{
RedisHelper.HashSet(key, sid, val);
}
return val;
}
public static void SetHashCache<T>(string key, string sid, T model)
{
RedisHelper.HashSet(key, sid, model);
}
public static void SetHashCache<T>(string key, Dictionary<string, T> dic)
{
RedisHelper.HashSet(key, dic);
}
public static Dictionary<string, T> GetHashAllCache<T>(string key)
{
return RedisHelper.HashGetAll<T>(key);
}
public static bool CheckKey(string key)
{
return RedisHelper.CheckKey(key);
}
}