/// <summary> /// 删除Redis数据库中的数据 /// </summary> /// <param name="ctx"></param> /// <param name="numbers"></param> /// <param name="dataType"></param> public virtual void RemoveRedisData(Context ctx, IEnumerable <string> numbers, SynchroDataType dataType = SynchroDataType.None) { long dbId = 0; if (this.K3CloudContext == null) { dbId = GetRedisDbId(ctx); } else { dbId = this.RedisDbId; } if (true /*K3LoginInfo.GetRedisServerIp(ctx).CompareTo(DataBaseConst.RedisServerIP) == 0*/) { List <string> infoKeys = null; RedisManager manager = new RedisManager(ctx); if (numbers != null && numbers.Count() > 0) { infoKeys = new List <string>(); foreach (var num in numbers) { if (!string.IsNullOrWhiteSpace(num)) { if (dataType.CompareTo(SynchroDataType.None) == 0) { infoKeys.Add(this.RedisInfoKey + num); manager.RemoveItemFromSet(ctx, this.RedisUnreadkey, num, dbId); } else { infoKeys.Add(RedisKeyUtils.GetRedisSetKey(dataType, this.Direction)["infoKey"] + num); manager.RemoveItemFromSet(ctx, RedisKeyUtils.GetRedisSetKey(dataType, this.Direction)["unreadKey"], num, dbId); } } } if (DataBaseConst.CurrentRedisServerIp.CompareTo(DataBaseConst.HKRedisIP) == 0) { manager.RemoveAll(ctx, infoKeys, this.RedisDbId); } manager = null; } } }
/// <summary> /// 删除Redis数据库中的数据 /// </summary> /// <param name="ctx"></param> /// <param name="numbers"></param> /// <param name="dataType"></param> public static void RemoveRedisData(Context ctx, IEnumerable <string> numbers, SynchroDirection direction, long RedisDbId, SynchroDataType dataType = SynchroDataType.None) { if (true /*K3LoginInfo.GetRedisServerIp(ctx).CompareTo(DataBaseConst.RedisServerIP) == 0*/) { List <string> infoKeys = null; RedisManager manager = new RedisManager(ctx); if (numbers != null && numbers.Count() > 0) { infoKeys = new List <string>(); foreach (var num in numbers) { if (!string.IsNullOrWhiteSpace(num)) { if (dataType.CompareTo(SynchroDataType.None) == 0) { infoKeys.Add(RedisInfoKey(dataType, direction) + num); manager.RemoveItemFromSet(ctx, RedisUnreadkey(dataType, direction), num, RedisDbId); } else { infoKeys.Add(RedisInfoKey(dataType, direction) + num); manager.RemoveItemFromSet(ctx, RedisUnreadkey(dataType, direction), num, RedisDbId); } } } if (DataBaseConst.CurrentRedisServerIp.CompareTo(DataBaseConst.HKRedisIP) == 0) { manager.RemoveAll(ctx, infoKeys, RedisDbId); } manager = null; } } }