当前位置: 编程技术>.net/c#/asp.net
.net/c# memcached缓存获取所有缓存键的方法步骤
来源: 互联网 发布时间:2014-08-25
本文导语: 使用组件memcached 1.2.6.net 类库 memcacheddotnet_clientlib-1.1.5 1.增加memcacheddotnet_clientlib-1.1.5代码 下载好组件后,用vs打开.net类库memcacheddotnet_clientlib-1.1.5,打开MemCachedClient.cs,增加如下方法: 代码如下:public Hashtable Stats(ArrayList servers, string c...
使用组件
memcached 1.2.6
.net 类库 memcacheddotnet_clientlib-1.1.5
1.增加memcacheddotnet_clientlib-1.1.5代码
下载好组件后,用vs打开.net类库memcacheddotnet_clientlib-1.1.5,打开MemCachedClient.cs,增加如下方法:
代码如下:
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 1)
{
int itemID = 0;
if (tmpArr[1] == "__") continue;
int.TryParse(tmpArr[1], out itemID);
if (itemID 1)
{
if (tmpArr[1] == "__")
{
continue;
}
keys.Add(tmpArr[0]);
}
}
}
return keys;
}
调用方法
代码如下:
IList list = MemcachedManager.GetAllKeys();
foreach (var item in list)
{
Response.Write(item + "
");
}