OpenAuth.Net/Infrastructure/Cache/EnyimMemcachedContext.cs

51 lines
1.4 KiB
C#
Raw Permalink 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 : Add services.AddEnyimMemcached(...)
// and app.UseEnyimMemcached() in Startup.
2016-07-08 22:52:40 +08:00
// 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
{
private IMemcachedClient _memcachedClient;
public EnyimMemcachedContext(IMemcachedClient client)
{
_memcachedClient = client;
}
2016-07-08 22:52:40 +08:00
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
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);
}
}
}