欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【.net/c# memcached缓存获取所有缓存键的方法步骤】,下面是详细的讲解!
.net/c# memcached缓存获取所有缓存键的方法步骤
public Hashtable Stats(ArrayList servers, string command)
{
// get SockIOPool instance
SockIOPool pool=SockIOPool.GetInstance(_poolName);
// return false if unable to get SockIO obj
if (pool==null)
{
//if(log.IsErrorEnabled)
//{
// log.Error(GetLocalizedString("unable to get socket pool"));
//}
return null;
}
// get all servers and iterate over them
if (servers==null)
servers=pool.Servers;
// if no servers, then return early
if (servers==null || servers.Count <=0)
{
//if(log.IsErrorEnabled)
//{
// log.Error(GetLocalizedString("stats no servers"));
//}
return null;
}
// array of stats Hashtables
Hashtable statsMaps=new Hashtable();
for (int i=0; i < servers.Count; i++)
{
SockIO sock=pool.GetConnection((string)servers[i]);
if (sock==null)
{
//if(log.IsErrorEnabled)
//{
// log.Error(GetLocalizedString("unable to connect").Replace("$$Server$$", servers[i].ToString()));
//}
continue;
}
// build command
if (command==null || command.Length==0)
{
command="stats\r\n";
}
else
{
command=command + "\r\n";
}
try
{
sock.Write(UTF8Encoding.UTF8.GetBytes(command));
sock.Flush();
// map to hold key value pairs
Hashtable stats=new Hashtable();
// loop over results
while (true)
{
string line=sock.ReadLine();
//if(log.IsDebugEnabled)
//{
// log.Debug(GetLocalizedString("stats line").Replace("$$Line$$", line));
//}
if (line.StartsWith(STATS))
{
string[] info=line.Split(' ');
string key=info[1];
string val=info[2];
//if(log.IsDebugEnabled)
//{
// log.Debug(GetLocalizedString("stats success").Replace("$$Key$$", key).Replace("$$Value$$", val));
//}
stats[key]=val;
}
else if (line.StartsWith("ITEM"))
{
string[] info=line.Split('[');
string key=info[0].Split(' ')[1];
string val="[" + info[1];
stats[key]=val;
}
else if (END==line)
{
// finish when we get end from server
//if(log.IsDebugEnabled)
//{
// log.Debug(GetLocalizedString("stats finished"));
//}
break;
}
statsMaps[servers[i]]=stats;
}
}
catch//(IOException e)
{
//if(log.IsErrorEnabled)
//{
// log.Error(GetLocalizedString("stats IOException"), e);
//}
try
{
sock.TrueClose();
}
catch//(IOException)
{
//if(log.IsErrorEnabled)
//{
// log.Error(GetLocalizedString("failed to close some socket").Replace("$$Socket$$", sock.ToString()));
//}
}
sock=null;
}
if (sock !=null)
sock.Close();
}
return statsMaps;
}
关于.net/c# memcached缓存获取所有缓存键的方法步骤的用户互动如下:
相关问题:在抽象工厂模式中怎样使用memcached缓存数据
答:你最好现描述清除你的问题或者需求,你的标题太宽泛,无法正确定位你的问题所在 抽象工程模式是一个对象创建型的设计模式,定义是:为创建一组相关或相互依赖的对象提供一个接口,而且无需指定他们的具体类 memcached是一个分布式的缓存数据库,... >>详细
相关问题:win7重建图标缓存????谁会啊
答:开始->所有程序->附件->命令提示符 或者 开始->运行->输入CMD 输入 attrib -h -s -r "%userprofile%\\AppData\\Local\\IconCache.db" del /f "%userprofile%\\AppData\\Local\\IconCache.db" attrib 直接回车即可清除win7重建图标缓存了! 也可... >>详细
相关问题:memcached 能连数据库吗
答:1 首先是通过java或者c#将数据从数据库读取出来,然后存储到memcached里面。 2 memcached 只是做缓存的,用不用数据库都可以,只要后台程序,如java或者C#连上memcached ,放数据就行。 memcached 简介 Memcached 是一个高性能的分布式内存对象... >>详细
- 【asp】asp.net url重写浅谈-net-url重写
- 【DataSet】DataSet、DataTable、DataRow区别详解
- 【asp】asp.net 动态添加多个用户控件-net-动态添
- 【创建】ASP.NET Web API教程 创建域模型的方法详
- 【Asp】Asp.net 页面调用javascript变量的值-net-
- 【ASP】ASP.NET 5升级后如何删除旧版本的DNX-NET5
- 【asp】asp.net ubb使用代码-net-ubb使用
- 【默认图片】图片不存在使用默认图片代替的实例
- 【asp】asp.net 页面转向 Response.Redirect Ser
- 【jQuery】jQuery实现倒计时跳转的例子-倒计时跳
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
