Web开发中,推荐缓存管理,缓存帮助类。


缓存管理:有一需求想找一个C#的缓存管理、缓存帮助类?类似于EnyimMemcached( EnyimMemcached )。

有经验的大家交流了,欢迎发言

ASP.NETMVC c#

镜子里的琥珀 11 years, 11 months ago
   
  public class Memcached
  
{
private static MemcachedClient client = null;

static Memcached ()
{
if (client == null)
{
MemcachedClientConfiguration config = new MemcachedClientConfiguration();
config.Servers.Add(new IPEndPoint(IPAddress.Parse(ip), prot));
config.Protocol = MemcachedProtocol.Binary;
client = new MemcachedClient(config);
}
}

public void Store( string key,object value, int minutes)
{
if (value != null)
client.Store(StoreMode.Set, key, value, new TimeSpan(0, 0, minutes * 60));
else
client.Remove(key);
}

public object Get(string key)
{
return client.Get(key);
}

}

oyasumi answered 11 years, 11 months ago

Your Answer