12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Reflection;
- using System.Configuration;
- namespace Bowin.Common.Cache
- {
- public static class CacheHelper
- {
- static readonly ICacheProvider cacheProvider = new HttpCacheProvider();
- static CacheHelper()
- {
- try
- {
- cacheProvider = (ICacheProvider)(typeof(ICacheProvider).Assembly.CreateInstance(ConfigurationManager.AppSettings["CacheProvider"]));
- }
- catch
- { }
- }
- public static object Add(string key, object entry)
- {
- return cacheProvider.Add(key, entry,DateTime.Now.AddHours(1f));
- }
- public static object Add(string key, object entry, DateTime utcExpiry)
- {
- return cacheProvider.Add(key, entry, utcExpiry);
- }
- public static object Get(string key)
- {
- return cacheProvider.Get(key);
- }
- public static void Remove(string key)
- {
- cacheProvider.Remove(key);
- }
- public static void Set(string key, object entry)
- {
- cacheProvider.Set(key, entry, DateTime.UtcNow.AddHours(1f));
- }
- public static void Set(string key, object entry, DateTime utcExpiry)
- {
- cacheProvider.Set(key, entry, utcExpiry);
- }
- }
- }
|