python写入:
from pymemcache.client.base import Client
client = Client(('127.0.0.1', 11211))
。。。
if __name__=='__main__':
print('正在运行资源监控程序...')
while True:
client.set('info_disk',getDisk())
client.set('info_net',getNet())
client.set('info_mem',getMemorystate())
client.set('info_cpu',getCPUstate(1))
c#读取:
string[] ips = System.Configuration.ConfigurationManager.AppSettings["MemcachedServers"].Split(',');
SockIOPool pool = SockIOPool.GetInstance();
pool.SetServers(ips);
pool.Initialize();
client = new MemcachedClient();
client.PrimitiveAsString = true;//加这个参数,可以与其他程序混写缓存
client.EnableCompression = true;
。。。。。。
MmHelper mm = new MmHelper();
string tt = mm.Get("info_cpu").ToString();
重要的是要设置这个参数:client.PrimitiveAsString = true;