OpenAuth.Net/Infrastructure/Cache/EnyimMemcachedContext.cs

38 lines
1.0 KiB
C#
Raw Normal View History

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
// ***********************************************************************
2016-12-27 11:25:51 +08:00
using System;
2016-07-08 22:52:40 +08:00
using Enyim.Caching;
using Enyim.Caching.Memcached;
2016-12-27 11:25:51 +08:00
namespace Infrastructure.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
{
2016-12-27 11:25:51 +08:00
private static readonly MemcachedClient _memcachedClient = new MemcachedClient();
2016-07-08 22:52:40 +08:00
public override T Get<T>(string key)
{
return _memcachedClient.Get<T>(key);
}
2016-12-27 11:25:51 +08:00
public override bool Set<T>(string key, T t, DateTime expire)
2016-07-08 22:52:40 +08:00
{
2016-12-27 11:25:51 +08:00
return _memcachedClient.Store(StoreMode.Set, key, t, expire);
2016-07-08 22:52:40 +08:00
}
public override bool Remove(string key)
{
return _memcachedClient.Remove(key);
}
}
}