1.简述
memcached官方并不提供原生的donet体系方案,
server端需要在linux环境下编译成windows下的exe包,
这里的server端为1.4.13版本,需要新版本的需要自己编译,
window体系下,使用memcached做缓存,建议采用“主从架构”,
业务缓存和配置缓存隔离,方便后期对缓存的升级维护优化
2.下载
------server端--------
https://pan.baidu.com/s/1QWxUlDnLkmRUgt_SsqOh7Q
-----client端---------
https://download.csdn.net/download/xuwei_xuwei/10464457
3.安装server端,4台服务器cmd执行如下命令
4.client端使用
public class MemcachedHelper
{
private static string MemcachedBusinessPoolName = "businesspool";
private static string[] businessList = new string[]{"192.168.100.102:11221", "192.168.100.103:11221" };
private static string MemcachedConfigPoolName = "configpool";
private static string[] configList = new string[] { "192.168.100.102:11222", "192.168.100.103:11222" };
private static MemcachedClient _businessClient;
private static MemcachedClient _configClient;
static MemcachedHelper()
{
InitBusinessPool();
_businessClient = new MemcachedClient
{
PoolName = MemcachedBusinessPoolName,
EnableCompression = false
};
InitConfigPool();
_configClient = new MemcachedClient
{
PoolName = MemcachedConfigPoolName,
EnableCompression = false
};
}
private static void InitBusinessPool()
{
SockIOPool businesspool = SockIOPool.GetInstance(MemcachedBusinessPoolName);
businesspool.SetServers(businessList);
businesspool.InitConnections = 10;
businesspool.MinConnections = 10;
businesspool.MaxConnections = 1000;
businesspool.SocketConnectTimeout = 1000;
businesspool.SocketTimeout = 3000;
businesspool.MaintenanceSleep = 30;
businesspool.Failover = true;
businesspool.Nagle = false;
businesspool.Initialize();
}
private static void InitConfigPool()
{
SockIOPool configpool = SockIOPool.GetInstance(MemcachedConfigPoolName);
configpool.SetServers(configList);
configpool.InitConnections = 10;
configpool.MinConnections = 10;
configpool.MaxConnections = 1000;
configpool.SocketConnectTimeout = 1000;
configpool.SocketTimeout = 3000;
configpool.MaintenanceSleep = 30;
configpool.Failover = true;
configpool.Nagle = false;
configpool.Initialize();
}
public static MemcachedClient GetBusinessClient()
{
return _businessClient;
}
public static MemcachedClient GetConfigClient()
{
return _configClient;
}
}
memcached官方并不提供原生的donet体系方案,
server端需要在linux环境下编译成windows下的exe包,
这里的server端为1.4.13版本,需要新版本的需要自己编译,
window体系下,使用memcached做缓存,建议采用“主从架构”,
业务缓存和配置缓存隔离,方便后期对缓存的升级维护优化
2.下载
------server端--------
https://pan.baidu.com/s/1QWxUlDnLkmRUgt_SsqOh7Q
-----client端---------
https://download.csdn.net/download/xuwei_xuwei/10464457
3.安装server端,4台服务器cmd执行如下命令
memcached1413.exe -d runservice -m 1024 -p 11211
4.client端使用
public class MemcachedHelper
{
private static string MemcachedBusinessPoolName = "businesspool";
private static string[] businessList = new string[]{"192.168.100.102:11221", "192.168.100.103:11221" };
private static string MemcachedConfigPoolName = "configpool";
private static string[] configList = new string[] { "192.168.100.102:11222", "192.168.100.103:11222" };
private static MemcachedClient _businessClient;
private static MemcachedClient _configClient;
static MemcachedHelper()
{
InitBusinessPool();
_businessClient = new MemcachedClient
{
PoolName = MemcachedBusinessPoolName,
EnableCompression = false
};
InitConfigPool();
_configClient = new MemcachedClient
{
PoolName = MemcachedConfigPoolName,
EnableCompression = false
};
}
private static void InitBusinessPool()
{
SockIOPool businesspool = SockIOPool.GetInstance(MemcachedBusinessPoolName);
businesspool.SetServers(businessList);
businesspool.InitConnections = 10;
businesspool.MinConnections = 10;
businesspool.MaxConnections = 1000;
businesspool.SocketConnectTimeout = 1000;
businesspool.SocketTimeout = 3000;
businesspool.MaintenanceSleep = 30;
businesspool.Failover = true;
businesspool.Nagle = false;
businesspool.Initialize();
}
private static void InitConfigPool()
{
SockIOPool configpool = SockIOPool.GetInstance(MemcachedConfigPoolName);
configpool.SetServers(configList);
configpool.InitConnections = 10;
configpool.MinConnections = 10;
configpool.MaxConnections = 1000;
configpool.SocketConnectTimeout = 1000;
configpool.SocketTimeout = 3000;
configpool.MaintenanceSleep = 30;
configpool.Failover = true;
configpool.Nagle = false;
configpool.Initialize();
}
public static MemcachedClient GetBusinessClient()
{
return _businessClient;
}
public static MemcachedClient GetConfigClient()
{
return _configClient;
}
}