1.Install-Package StackExchange -v
2.using StackExchange.Redis;
3.
static void StackExchangeRedisDemo() { using(ConnectionMultiplexer redis=ConnectionMultiplexer.Connect("localhost,allowAdmin=true")) { var endPoint = redis.GetEndPoints().FirstOrDefault(); var redisServer = redis.GetServer(endPoint); redisServer.FlushDatabase(); IDatabase db = redis.GetDatabase(0); DateTime dt = DateTime.Now; DateTime dtEnd = dt.AddSeconds(60); int num = 0; List<string> keysList = new List<string>(); while (DateTime.Now<dtEnd) { num++; string redisKey = Guid.NewGuid().ToString(); keysList.Add(redisKey); db.StringSetAsync(redisKey, Guid.NewGuid().ToString()); } ThreadPool.SetMinThreads(200, 200); System.Diagnostics.Debug.WriteLine($"redisServer.Keys().Count():{redisServer.Keys().Count()}\n,num:{num}"); } }