當前位置: 首頁>>代碼示例>>C#>>正文


C# RedisClient.GetAllKeys方法代碼示例

本文整理匯總了C#中ServiceStack.Redis.RedisClient.GetAllKeys方法的典型用法代碼示例。如果您正苦於以下問題:C# RedisClient.GetAllKeys方法的具體用法?C# RedisClient.GetAllKeys怎麽用?C# RedisClient.GetAllKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ServiceStack.Redis.RedisClient的用法示例。


在下文中一共展示了RedisClient.GetAllKeys方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: findlen

        static void findlen()
        {
            using (var redisClient = new RedisClient(redisHost, Convert.ToInt16(redisPort)))
            {
                double totalsize = 0;
                var keys = redisClient.GetAllKeys();
                foreach (string key in keys)
                {
                    try
                    {
                        byte[] bytarr = redisClient.Get(key);
                        double kblen = ConvertBytesToKilobytes(bytarr.Length);
                        double mblen = ConvertBytesToMegabytes(bytarr.Length);
                        totalsize = totalsize + mblen;
                        Console.WriteLine("Key Name : " + key + " Key length in MB : " + mblen + " Key Length in Kb : " + kblen);
                        using (System.IO.StreamWriter file = new System.IO.StreamWriter(@FilePathToStoreResult, true))
                        {
                            file.WriteLine("Key Name : " + key + " Key length in MB : " + mblen + " Key Length in Kb : " + kblen);
                        }

                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            byte[][] bythsharr = redisClient.HGetAll(key);
                            double kblen = ConvertBytesToKilobytes(bythsharr.Length);
                            double mblen = ConvertBytesToMegabytes(bythsharr.Length);
                            Console.WriteLine("Hash Key Name : " + key + " Key length in MB : " + mblen + " Key Length in Kb : " + kblen);
                            using (System.IO.StreamWriter file =new System.IO.StreamWriter(@FilePathToStoreResult, true))
                            {
                                file.WriteLine("Hash Key Name : " + key + " Key length in MB : " + mblen + " Key Length in Kb : " + kblen);
                            }
                            totalsize = totalsize + mblen;
                        }
                        catch (Exception ex1)
                        {

                        }
                    }
                }
            }
        }
開發者ID:abhiyx,項目名稱:RedisSizeCalculator,代碼行數:43,代碼來源:Program.cs

示例2: button2_Click

 private void button2_Click(object sender, EventArgs e)
 {
     // This is to dump everything
     RedisClient client = new RedisClient(txtHost.Text, 6379, txtAuth.Text.Trim(), int.Parse(txtDBNo.Text));
     var all_keys = client.GetAllKeys();
     var sw = new StreamWriter("dump.txt");
     int i = 1;
     foreach (var key in all_keys)
     {
         //write key
         sw.WriteLine(key);
         var value = client.Dump(key);
         var file = File.OpenWrite(i.ToString() + ".txt");
         file.Write(value, 0, value.Length);
         file.Close();
         i++;
     }
     sw.Close();
     MessageBox.Show("Done");
 }
開發者ID:shawhu,項目名稱:redis-backup-restore,代碼行數:20,代碼來源:Form1.cs

示例3: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     using (var redisClient = new RedisClient("localhost"))
     {
         var k = Request["k"];
         if(!string.IsNullOrEmpty(k))
         {
             var obj = redisClient.Get(k);
             if(obj != null)
             {
                 string result = System.Text.Encoding.UTF8.GetString(obj);
                 Response.Write(result);
             }
             return;
         }
         foreach (var _key in redisClient.GetAllKeys())
         {
             Response.Write(string.Format(@"<a href=""?k={0}"">{0}</a><br/>", _key));
         }
     }
 }
開發者ID:nhatkycon,項目名稱:xetui,代碼行數:21,代碼來源:Key.aspx.cs


注:本文中的ServiceStack.Redis.RedisClient.GetAllKeys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。