本文整理汇总了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)
{
}
}
}
}
}
示例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");
}
示例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));
}
}
}