/ Published in: C#
Expand |
Embed | Plain Text
public class Cache { public static void Add(string name, object data, int hours) { HttpContext.Current.Cache.Insert(name, data, null, DateTime.Now.AddHours(hours), TimeSpan.Zero); } public static object Get(string name) { if (HttpContext.Current.Cache[name] != null) return HttpContext.Current.Cache[name]; else return null; } } Clear: foreach (DictionaryEntry entry in Cache) Cache.Remove(entry.Key.ToString());
You need to login to post a comment.
