public static void Insert(IKeyPrefix prefix, string key, object obj, CacheDependency dep = null, CacheItemPriority priority = CacheItemPriority.Normal) { if (obj != null) { string realKey = prefix.Prefix + ":" + key; CacheContainer.Insert(realKey, obj, dep, prefix.ExpireSeconds <= 0 ? DateTime.MaxValue : DateTime.Now.AddSeconds(prefix.ExpireSeconds), TimeSpan.Zero, priority, null); } }
public static object Get(IKeyPrefix prefix, string key) { string realKey = prefix.Prefix + ":" + key; Object cacheObject = CacheContainer[realKey]; if (cacheObject != null) { string oType = cacheObject.GetType().Name.ToString(); if (oType.IndexOf("[]") > 0) { if (((Array)cacheObject).Length == 0) { return(null); } else { return(cacheObject); } } } return(cacheObject); }
public static void Remove(IKeyPrefix prefix, string key) { CacheContainer.Remove(prefix.Prefix + ":" + key); }