2016-07-08 22:52:40 +08:00
|
|
|
|
// ***********************************************************************
|
|
|
|
|
// Assembly : Infrastructure
|
|
|
|
|
// Author : yubaolee
|
|
|
|
|
// Created : 06-21-2016
|
|
|
|
|
//
|
|
|
|
|
// Last Modified By : yubaolee
|
|
|
|
|
// Last Modified On : 06-21-2016
|
|
|
|
|
// Contact :
|
|
|
|
|
// File: EnyimMemcachedContext.cs
|
|
|
|
|
// ***********************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using Enyim.Caching;
|
|
|
|
|
using Enyim.Caching.Memcached;
|
|
|
|
|
|
2016-11-17 19:48:12 +08:00
|
|
|
|
namespace Helper.Cache
|
2016-07-08 22:52:40 +08:00
|
|
|
|
{
|
2016-11-17 19:48:12 +08:00
|
|
|
|
public sealed class EnyimMemcachedContext : ICacheContext
|
2016-07-08 22:52:40 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly MemcachedClient _memcachedClient = new MemcachedClient("memcached");
|
|
|
|
|
|
|
|
|
|
public override void Init()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override T Get<T>(string key)
|
|
|
|
|
{
|
|
|
|
|
return _memcachedClient.Get<T>(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Set<T>(string key, T t)
|
|
|
|
|
{
|
|
|
|
|
return _memcachedClient.Store(StoreMode.Set, key, t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Remove(string key)
|
|
|
|
|
{
|
|
|
|
|
return _memcachedClient.Remove(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Dispose()
|
|
|
|
|
{
|
|
|
|
|
if (_memcachedClient != null)
|
|
|
|
|
{
|
|
|
|
|
_memcachedClient.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|