679 lines
24 KiB
C#
679 lines
24 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Linq;
|
||
using System.Threading.Tasks;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.DAL.Redis;
|
||
using WX.CRM.IBLL.Redis;
|
||
using WX.CRM.Model.EntitySync;
|
||
using WX.CRM.Model.Redis;
|
||
|
||
namespace WX.CRM.BLL.Redis
|
||
{
|
||
public class RedisTestHelper : RedisHelper, IRedisTestHelper
|
||
{
|
||
public override bool AddToCache(REDIS_CACHE_SSODATASYNC info)
|
||
{
|
||
RedisString<string> redis = new RedisString<string>("test1");
|
||
return redis.Set("呵呵哒");
|
||
}
|
||
}
|
||
|
||
public class RedisObjectHelper : RedisHelper, IRedisObjectHelper
|
||
{
|
||
public async void Run(REDIS_CACHE_SSODATASYNC info)
|
||
{
|
||
if (info == null)
|
||
throw new Exception("REDIS_CACHE_SSODATASYNC IS NULL");
|
||
try
|
||
{
|
||
//获取配置
|
||
var cacheTableType = GetCacheTableType(info.TABLETYPE);
|
||
if (cacheTableType == null)
|
||
{
|
||
LogHelper.Error("cacheTableType:未能获取到配置表数据");
|
||
throw new Exception(string.Format("REDIS_CACHE_SSODATASYNC:{0},配置错误", info.TABLETYPE));
|
||
}
|
||
|
||
//获取数据
|
||
var dt = LoadDataAndSerialize(cacheTableType, info.PKID);
|
||
|
||
LogHelper.Info(string.Format("类型:{0},Count:{1}", cacheTableType.TABLECODE, dt.Rows.Count));
|
||
if (dt != null && dt.Rows.Count > 0)
|
||
{
|
||
#region OldVersion
|
||
//var list = Utility.DataTableToList(dt);
|
||
//dt.Clear();
|
||
//dt.Dispose();
|
||
//foreach (var item in list)
|
||
//{
|
||
// #region
|
||
// //获取写入redis的key
|
||
// var id = string.Empty;
|
||
// foreach (KeyValuePair<string, object> keyValuePair in item)
|
||
// {
|
||
// if (keyValuePair.Key.ToLower() == cacheTableType.KEYFIELD.ToLower())
|
||
// {
|
||
// id = keyValuePair.Value.ToString();
|
||
// }
|
||
// }
|
||
|
||
// if (!string.IsNullOrEmpty(id))
|
||
// {
|
||
// var opType = (OpTypeEnum)Enum.Parse(typeof(OpTypeEnum), info.OPTYPE);
|
||
// switch (opType)
|
||
// {
|
||
// case OpTypeEnum.R:
|
||
// UpdateCache(cacheTableType.TABLENAME + ":" + id, item);
|
||
// break;
|
||
// case OpTypeEnum.A:
|
||
// await AddToCacheAsync(cacheTableType.TABLENAME + ":" + id, item);
|
||
// break;
|
||
// case OpTypeEnum.U:
|
||
// UpdateCache(cacheTableType.TABLENAME + ":" + id, item);
|
||
// break;
|
||
// case OpTypeEnum.D:
|
||
// DeleteCache(cacheTableType.TABLENAME + ":" + id);
|
||
// break;
|
||
// }
|
||
// }
|
||
// #endregion
|
||
//}
|
||
//list.Clear();
|
||
#endregion
|
||
|
||
var redisType = (RedisTypeEnum)Enum.Parse(typeof(RedisTypeEnum), cacheTableType.REDISTYPE);
|
||
switch (redisType)
|
||
{
|
||
case RedisTypeEnum.Str:
|
||
await SetCache(info, cacheTableType, dt);
|
||
break;
|
||
case RedisTypeEnum.Hash:
|
||
await new RedisHashHelper().SetCache(info, cacheTableType, dt);
|
||
break;
|
||
case RedisTypeEnum.List:
|
||
await new RedisListHelper().SetCache(info, cacheTableType, dt);
|
||
break;
|
||
case RedisTypeEnum.Set:
|
||
await new RedisSetHelper().SetCache(info, cacheTableType, dt);
|
||
break;
|
||
case RedisTypeEnum.Zset:
|
||
await new RedisSortedSetHelper().SetCache(info, cacheTableType, dt);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("【打包调度】WX.CRM.RedisDataSynService.RedisHelper.Run()错误:" + ex.Message + ex.StackTrace);
|
||
}
|
||
|
||
}
|
||
|
||
public async Task SetCache(REDIS_CACHE_SSODATASYNC info, REDIS_CACHE_TABLETYPE cfg, DataTable dt)
|
||
{
|
||
var config = GetRedisConfig(cfg.TABLENAME + ":");
|
||
var opType = (OpTypeEnum)Enum.Parse(typeof(OpTypeEnum), info.OPTYPE);
|
||
var list = Utility.DataTableToList(dt);
|
||
dt.Clear();
|
||
dt.Dispose();
|
||
foreach (var item in list)
|
||
{
|
||
#region
|
||
//获取写入redis的key
|
||
var id = string.Empty;
|
||
foreach (KeyValuePair<string, object> keyValuePair in item)
|
||
{
|
||
if (keyValuePair.Key.ToLower() == cfg.KEYFIELD.ToLower())
|
||
{
|
||
id = keyValuePair.Value.ToString();
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(id))
|
||
{
|
||
switch (opType)
|
||
{
|
||
case OpTypeEnum.R:
|
||
UpdateCache(cfg.TABLENAME + ":" + id, item);
|
||
break;
|
||
case OpTypeEnum.A:
|
||
await AddToCacheAsync(cfg.TABLENAME + ":" + id, item);
|
||
break;
|
||
case OpTypeEnum.U:
|
||
UpdateCache(cfg.TABLENAME + ":" + id, item);
|
||
break;
|
||
case OpTypeEnum.D:
|
||
DeleteCache(cfg.TABLENAME + ":" + id);
|
||
break;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
list.Clear();
|
||
}
|
||
}
|
||
|
||
public class RedisListHelper : RedisHelper
|
||
{
|
||
public async Task SetCache(REDIS_CACHE_SSODATASYNC info, REDIS_CACHE_TABLETYPE cfg, DataTable dt)
|
||
{
|
||
var config = GetRedisConfig(cfg.TABLENAME + ":");
|
||
var opType = (OpTypeEnum)Enum.Parse(typeof(OpTypeEnum), info.OPTYPE);
|
||
RedisList<object> redis = new RedisList<object>(config);
|
||
var list = Utility.DataTableToList(dt);
|
||
dt.Clear();
|
||
dt.Dispose();
|
||
foreach (var item in list)
|
||
{
|
||
#region
|
||
//获取写入redis的key
|
||
var id = string.Empty;
|
||
foreach (KeyValuePair<string, object> keyValuePair in item.Where(keyValuePair => keyValuePair.Key.ToLower() == cfg.KEYFIELD.ToLower()))
|
||
{
|
||
id = keyValuePair.Value.ToString();
|
||
}
|
||
if (string.IsNullOrEmpty(id))
|
||
{
|
||
throw new Exception("写入key为空!");
|
||
}
|
||
switch (opType)
|
||
{
|
||
case OpTypeEnum.R:
|
||
await redis.LeftPushAsync(cfg.TABLENAME + ":" + id, item);
|
||
break;
|
||
case OpTypeEnum.A:
|
||
await redis.LeftPushAsync(cfg.TABLENAME + ":" + id, item);
|
||
break;
|
||
case OpTypeEnum.U:
|
||
await redis.LeftPushAsync(cfg.TABLENAME + ":" + id, item);
|
||
break;
|
||
case OpTypeEnum.D:
|
||
await redis.RemoveAsync(cfg.TABLENAME + ":" + id, item);
|
||
break;
|
||
}
|
||
#endregion
|
||
}
|
||
list.Clear();
|
||
}
|
||
}
|
||
|
||
public class RedisHashHelper : RedisHelper, IRedisHashHelper
|
||
{
|
||
public async Task SetCache(REDIS_CACHE_SSODATASYNC info, REDIS_CACHE_TABLETYPE cfg, DataTable dt)
|
||
{
|
||
var config = GetRedisConfig(cfg.TABLENAME + ":");
|
||
RedisHash<object> redis = new RedisHash<object>(config);
|
||
var opType = (OpTypeEnum)Enum.Parse(typeof(OpTypeEnum), info.OPTYPE);
|
||
var list = Utility.DataTableToList(dt);
|
||
dt.Clear();
|
||
dt.Dispose();
|
||
foreach (var item in list)
|
||
{
|
||
#region
|
||
//获取写入redis的key
|
||
var id = string.Empty;
|
||
IList<KeyValuePair<object, object>> l = new List<KeyValuePair<object, object>>();
|
||
foreach (KeyValuePair<string, object> keyValuePair in item)
|
||
{
|
||
if (keyValuePair.Key.ToLower() == cfg.KEYFIELD.ToLower())
|
||
{
|
||
id = keyValuePair.Value.ToString();
|
||
}
|
||
l.Add(new KeyValuePair<object, object>(keyValuePair.Key, keyValuePair.Value));
|
||
}
|
||
if (string.IsNullOrEmpty(id))
|
||
{
|
||
throw new Exception("写入key为空!");
|
||
}
|
||
switch (opType)
|
||
{
|
||
case OpTypeEnum.R:
|
||
await redis.SetByListAsync(cfg.TABLENAME + ":" + id, l);
|
||
break;
|
||
case OpTypeEnum.A:
|
||
await redis.SetByListAsync(cfg.TABLENAME + ":" + id, l);
|
||
break;
|
||
case OpTypeEnum.U:
|
||
await redis.SetByListAsync(cfg.TABLENAME + ":" + id, l);
|
||
break;
|
||
case OpTypeEnum.D:
|
||
await redis.DelAsync(cfg.TABLENAME + ":" + id);
|
||
//await DeleteCacheAsync(cfg.TABLENAME + ":" + id);
|
||
break;
|
||
}
|
||
#endregion
|
||
}
|
||
list.Clear();
|
||
}
|
||
|
||
public new T Get<T>(string key) where T : class, new()
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
return Get<T>(key, config);
|
||
}
|
||
|
||
public new T Get<T>(string key, RedisConfig config) where T : class, new()
|
||
{
|
||
RedisClass<T> redis = new RedisClass<T>(key, config);
|
||
return redis.Get();
|
||
}
|
||
|
||
public new Task<T> GetAsync<T>(string key) where T : class, new()
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
return GetAsync<T>(key, config);
|
||
}
|
||
public new Task<T> GetAsync<T>(string key, RedisConfig config) where T : class, new()
|
||
{
|
||
RedisClass<T> redis = new RedisClass<T>(key, config);
|
||
return redis.GetAsync();
|
||
}
|
||
public override bool AddToCache<T>(string key, T data)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
return AddToCache(key, data, config);
|
||
}
|
||
|
||
public override bool AddToCache<T>(string key, T data, RedisConfig config)
|
||
{
|
||
RedisHash<object> redis = new RedisHash<object>(key, config);
|
||
return redis.Set<T>(key, data);
|
||
}
|
||
|
||
public override Task<bool> AddToCacheAsync<T>(string key, T data)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
return AddToCacheAsync(key, data, config);
|
||
}
|
||
|
||
public override Task<bool> AddToCacheAsync<T>(string key, T data, RedisConfig config)
|
||
{
|
||
RedisHash<object> redis = new RedisHash<object>(key, config);
|
||
return redis.SetAsync<T>(key, data);
|
||
}
|
||
|
||
public override bool DeleteCache(string key)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
return DeleteCache(key, config);
|
||
}
|
||
|
||
public override bool DeleteCache(string key, RedisConfig config)
|
||
{
|
||
RedisHash<object> redis = new RedisHash<object>(key, config);
|
||
return redis.Del();
|
||
}
|
||
|
||
public override Task<bool> DeleteCacheAsync(string key)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
return DeleteCacheAsync(key, config);
|
||
}
|
||
|
||
public override Task<bool> DeleteCacheAsync(string key, RedisConfig config)
|
||
{
|
||
RedisHash<object> redis = new RedisHash<object>(key, config);
|
||
return redis.DelAsync();
|
||
}
|
||
|
||
public override bool AddToCache(REDIS_CACHE_SSODATASYNC info)
|
||
{
|
||
try
|
||
{
|
||
|
||
return true;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex);
|
||
return false;
|
||
}
|
||
}
|
||
|
||
public override bool UpdateCache(REDIS_CACHE_SSODATASYNC info)
|
||
{
|
||
try
|
||
{
|
||
|
||
return true;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex);
|
||
return false;
|
||
}
|
||
}
|
||
|
||
public override bool DeleteCache(REDIS_CACHE_SSODATASYNC info)
|
||
{
|
||
try
|
||
{
|
||
|
||
return true;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex);
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
|
||
public class RedisSetHelper : RedisHelper
|
||
{
|
||
public async Task SetCache(REDIS_CACHE_SSODATASYNC info, REDIS_CACHE_TABLETYPE cfg, DataTable dt)
|
||
{
|
||
var config = GetRedisConfig(cfg.TABLENAME + ":");
|
||
var opType = (OpTypeEnum)Enum.Parse(typeof(OpTypeEnum), info.OPTYPE);
|
||
RedisSet<object> redis = new RedisSet<object>(config);
|
||
var list = Utility.DataTableToList(dt);
|
||
foreach (var item in list)
|
||
{
|
||
#region
|
||
//获取写入redis的key
|
||
var id = string.Empty;
|
||
object data = string.Empty;
|
||
foreach (KeyValuePair<string, object> keyValuePair in item)
|
||
{
|
||
if (keyValuePair.Key.ToLower() == cfg.KEYFIELD.ToLower())
|
||
{
|
||
id = keyValuePair.Value.ToString();
|
||
}
|
||
if (keyValuePair.Key.ToLower() == "v")
|
||
{
|
||
data = keyValuePair.Value;
|
||
}
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(id))
|
||
{
|
||
switch (opType)
|
||
{
|
||
case OpTypeEnum.R:
|
||
await redis.AddAsync(cfg.TABLENAME + ":" + id, data);
|
||
break;
|
||
case OpTypeEnum.A:
|
||
await redis.AddAsync(cfg.TABLENAME + ":" + id, data);
|
||
break;
|
||
case OpTypeEnum.U:
|
||
await redis.AddAsync(cfg.TABLENAME + ":" + id, data);
|
||
break;
|
||
case OpTypeEnum.D:
|
||
await redis.RemoveAsync(cfg.TABLENAME + ":" + id, data);
|
||
break;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
}
|
||
}
|
||
|
||
public class RedisSortedSetHelper : RedisHelper
|
||
{
|
||
public async Task SetCache(REDIS_CACHE_SSODATASYNC info, REDIS_CACHE_TABLETYPE cfg, DataTable dt)
|
||
{
|
||
var config = GetRedisConfig(cfg.TABLENAME + ":");
|
||
var opType = (OpTypeEnum)Enum.Parse(typeof(OpTypeEnum), info.OPTYPE);
|
||
RedisSortedSet<object> redis = new RedisSortedSet<object>(config);
|
||
var list = Utility.DataTableToList(dt);
|
||
foreach (var item in list)
|
||
{
|
||
#region
|
||
var id = string.Empty;
|
||
object data = string.Empty;
|
||
double score = 0;
|
||
foreach (KeyValuePair<string, object> keyValuePair in item)
|
||
{
|
||
if (keyValuePair.Key.ToLower() == cfg.KEYFIELD.ToLower())
|
||
{
|
||
id = keyValuePair.Value.ToString();
|
||
}
|
||
if (keyValuePair.Key.ToLower() == "v")
|
||
{
|
||
data = keyValuePair.Value;
|
||
}
|
||
if (keyValuePair.Key.ToLower() == "score")
|
||
{
|
||
score = double.Parse(keyValuePair.Value.ToString());
|
||
}
|
||
}
|
||
if (string.IsNullOrEmpty(id))
|
||
{
|
||
throw new Exception("写入key为空!");
|
||
}
|
||
switch (opType)
|
||
{
|
||
case OpTypeEnum.R:
|
||
await redis.AddAsync(cfg.TABLENAME + ":" + id, data, score);
|
||
break;
|
||
case OpTypeEnum.A:
|
||
await redis.AddAsync(cfg.TABLENAME + ":" + id, data, score);
|
||
break;
|
||
case OpTypeEnum.U:
|
||
await redis.AddAsync(cfg.TABLENAME + ":" + id, data, score);
|
||
break;
|
||
case OpTypeEnum.D:
|
||
await redis.DelAsync(cfg.TABLENAME + ":" + id);
|
||
break;
|
||
}
|
||
#endregion
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
public class RedisHelper : IRedisHelper
|
||
{
|
||
public RedisConfig GetRedisConfig(string key)
|
||
{
|
||
RedisConfig config = RedisConfig.Redis0;
|
||
var k = key.Substring(0, key.IndexOf(':'));
|
||
var redisTypeList = new REDIS_Util_BL().GetTableType_CacheList();
|
||
var redisCacheTabletype = redisTypeList.FirstOrDefault(p => p.TABLENAME == k);
|
||
if (redisCacheTabletype != null)
|
||
{
|
||
var redisType = redisCacheTabletype.REDISDB;
|
||
config = (RedisConfig)Enum.Parse(typeof(RedisConfig), redisType);
|
||
}
|
||
return config;
|
||
}
|
||
|
||
public void SendMsgWaitToSync(REDIS_CACHE_SSODATASYNC info)
|
||
{
|
||
using (WX.CRM.Model.EntitySync.Entities db = new WX.CRM.Model.EntitySync.Entities())
|
||
{
|
||
db.REDIS_CACHE_SSODATASYNC.Add(info);
|
||
db.SaveChanges();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取配置信息
|
||
/// </summary>
|
||
/// <param name="tableCode"></param>
|
||
/// <returns></returns>
|
||
public REDIS_CACHE_TABLETYPE GetCacheTableType(string tableCode)
|
||
{
|
||
var cacheTableTypeList = new REDIS_Util_BL().GetTableType_CacheList();
|
||
var cacheTableType = cacheTableTypeList.FirstOrDefault(p => p.TABLECODE == tableCode);
|
||
return cacheTableType;
|
||
}
|
||
/// <summary>
|
||
/// loadData
|
||
/// </summary>
|
||
/// <param name="cacheTableType"></param>
|
||
/// <returns></returns>
|
||
public DataTable LoadDataAndSerialize(REDIS_CACHE_TABLETYPE cacheTableType, decimal pkid)
|
||
{
|
||
return new LoadDataToRedis().LoadDataToCache(cacheTableType.STOREPROCEDURE, cacheTableType.TABLECODE, pkid);
|
||
}
|
||
|
||
public virtual T Get<T>(string key)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return redis.Get();
|
||
}
|
||
|
||
public virtual T Get<T>(string key, RedisConfig config)
|
||
{
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return redis.Get();
|
||
}
|
||
|
||
public virtual async Task<T> GetAsync<T>(string key)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return await redis.GetAsync();
|
||
}
|
||
|
||
public virtual async Task<T> GetAsync<T>(string key, RedisConfig config)
|
||
{
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return await redis.GetAsync();
|
||
}
|
||
|
||
public virtual List<T> GetList<T>(string[] keys)
|
||
{
|
||
return (from key in keys let config = GetRedisConfig(key) select new RedisString<T>(key, config) into redis select redis.Get()).ToList();
|
||
}
|
||
|
||
public virtual List<T> GetList<T>(string[] keys, RedisConfig config)
|
||
{
|
||
return keys.Select(key => new RedisString<T>(key, config)).Select(redis => redis.Get()).ToList();
|
||
}
|
||
|
||
public virtual async Task<List<T>> GetListAsync<T>(string[] keys)
|
||
{
|
||
var list = new List<T>();
|
||
foreach (var redis in from key in keys let config = GetRedisConfig(key) select new RedisString<T>(key, config))
|
||
{
|
||
list.Add(await redis.GetAsync());
|
||
}
|
||
return list;
|
||
}
|
||
|
||
public virtual async Task<List<T>> GetListAsync<T>(string[] keys, RedisConfig config)
|
||
{
|
||
var list = new List<T>();
|
||
foreach (var redis in keys.Select(key => new RedisString<T>(key, config)))
|
||
{
|
||
list.Add(await redis.GetAsync());
|
||
}
|
||
return list;
|
||
}
|
||
|
||
public virtual bool AddToCache<T>(string key, T data)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return redis.Set(data);
|
||
}
|
||
|
||
public virtual bool AddToCache<T>(string key, T data, RedisConfig config)
|
||
{
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return redis.Set(data);
|
||
}
|
||
|
||
public virtual async Task<bool> AddToCacheAsync<T>(string key, T data)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return await redis.SetAsync(data);
|
||
}
|
||
|
||
public virtual async Task<bool> AddToCacheAsync<T>(string key, T data, RedisConfig config)
|
||
{
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return await redis.SetAsync(data);
|
||
}
|
||
|
||
public virtual bool UpdateCache<T>(string key, T data)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return redis.Set(data);
|
||
}
|
||
|
||
public virtual bool UpdateCache<T>(string key, T data, RedisConfig config)
|
||
{
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return redis.Set(data);
|
||
}
|
||
|
||
public virtual async Task<bool> UpdateCacheAsync<T>(string key, T data)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return await redis.SetAsync(data);
|
||
}
|
||
|
||
public virtual async Task<bool> UpdateCacheAsync<T>(string key, T data, RedisConfig config)
|
||
{
|
||
RedisString<T> redis = new RedisString<T>(key, config);
|
||
return await redis.SetAsync(data);
|
||
}
|
||
|
||
public virtual bool DeleteCache(string key)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
RedisString<object> redis = new RedisString<object>(key, config);
|
||
return redis.Del();
|
||
}
|
||
|
||
public virtual bool DeleteCache(string key, RedisConfig config)
|
||
{
|
||
RedisString<object> redis = new RedisString<object>(key, config);
|
||
return redis.Del();
|
||
}
|
||
|
||
public virtual async Task<bool> DeleteCacheAsync(string key)
|
||
{
|
||
var config = GetRedisConfig(key);
|
||
RedisString<object> redis = new RedisString<object>(key, config);
|
||
return await redis.DelAsync();
|
||
}
|
||
|
||
public virtual async Task<bool> DeleteCacheAsync(string key, RedisConfig config)
|
||
{
|
||
RedisString<object> redis = new RedisString<object>(key, config);
|
||
return await redis.DelAsync();
|
||
}
|
||
|
||
public virtual bool AddToCache(REDIS_CACHE_SSODATASYNC info)
|
||
{
|
||
throw new NotImplementedException("请实现该方法");
|
||
}
|
||
|
||
public virtual bool UpdateCache(REDIS_CACHE_SSODATASYNC info)
|
||
{
|
||
throw new NotImplementedException("请实现该方法");
|
||
}
|
||
|
||
public virtual bool DeleteCache(REDIS_CACHE_SSODATASYNC info)
|
||
{
|
||
throw new NotImplementedException("请实现该方法");
|
||
}
|
||
}
|
||
|
||
public enum OpTypeEnum
|
||
{
|
||
R = 0,
|
||
A = 1,
|
||
U = 2,
|
||
D = 3
|
||
}
|
||
|
||
public enum RedisTypeEnum
|
||
{
|
||
Str = 0,
|
||
Hash = 1,
|
||
List = 2,
|
||
Set = 3,
|
||
Zset = 4
|
||
}
|
||
}
|