方法:
/// <summary> /// 清除redis所有缓存 /// </summary> /// <param name="redisUrl"></param> public static void RemoveAllRedisCache(string redisUrl) { using (RedisClient redisClient = new RedisClient(redisUrl)) using (var redisManager = new RedisManagerPool(redisUrl)) { IRedisClient redis = redisManager.GetClient(); List<string> list = redis.GetAllKeys(); redis.RemoveAll(list); } }
调用:
static void Main(string[] args) { string RedisUrl = "[email protected]:6379"; RemoveAllRedisCache(RedisUrl); Console.WriteLine("清理成功"); Console.ReadKey(); }
时间: 2024-10-12 19:03:35