zoukankan      html  css  js  c++  java
  • C# redis StackExchange

    1.Install-Package StackExchange -v 2.0.601

    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()}
    ,num:{num}");
                }
            }
  • 相关阅读:
    C++实现base64编解码
    使用matplotlib绘制3D函数图像
    C++分治策略实现快速排序
    C++分治策略实现二分搜索
    C++生成随机数
    eBay 表结构
    mysql 流程函数
    无限极分类
    PHP 导出 Excell
    js
  • 原文地址:https://www.cnblogs.com/Fred1987/p/11892572.html
Copyright © 2011-2022 走看看