c#读取 redis中hash类型的数据

时间:2025-03-27 14:46:37

        //linux服务器地址

        static private string host = "127.0.0.1";
        //static private string host = "127.0.0.1";
        static private int port = 6376;
        static RedisClient redisClient = new RedisClient(host, port);//redis服务IP和端口
       
        private void RedisDemo_Load(object sender, EventArgs e)
        {
            = "abcd+1234";//密码 没有可以注释
            var hashKeys = ("h_license");  //获取key         
            foreach (var key in hashKeys)
            {
                ("HashId--Key:{0}", key);
            }
         var haskValues = ("h_license");//获取value
            foreach (var value in haskValues)
            {
                ("HashId--Value:{0}", value);
            }
            var allKeys = (); //获取所有的key。
            foreach (var key in allKeys)
            {
                ("AllKey--Key:{0}", key);

            }

             var dic1 = ("h_license");//同时获取key和value
            ("Key-----Value");
            foreach (var keyVal in dic1)
            {
                (("{0}-----{1}", , ));
            }

            ();
        }

相关文章