OpenAuth.Net/Infrastructure/Cache/ObjCacheProvider.cs
2016-12-27 11:25:51 +08:00

49 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ***********************************************************************
// Assembly : Helper
// Author : Administrator
// Created : 12-21-2016
//
// Last Modified By : Administrator
// Last Modified On : 12-22-2016
// Contact :
// File: ObjCacheProvider.cs
// ***********************************************************************
using System;
namespace Infrastructure.Cache
{
/// <summary>
/// 缓存工厂实现
/// 这样做是方便换其他的缓存时如memcachedContext只换这一个地方即可
/// </summary>
public class ObjCacheProvider<T> : CacheProvider
{
public ObjCacheProvider()
{
SetCacheInstance(new CacheContext());
}
public bool Create(string key, T val, DateTime expire)
{
//设置缓存
return CacheContext.Set<T>(key, val, expire);
}
/// <summary>
/// 根据失效时间获取缓存
/// <para>李玉宝于2016-11-08 16:54:04</para>
/// </summary>
/// <param name="key">The key.</param>
public T GetCache(string key)
{
return CacheContext.Get<T>(key);
}
public void Remove(string key)
{
CacheContext.Remove(key);
}
}
}