public static void AddToCache(this object obj, string cacheType, string childKey, CacheDependency cacheDependency, CacheFactor objCacheFactor, int numeral, CacheItemPriority priority, CacheItemRemovedCallback cacheItemRemovedCallback) { if (cacheType.IsNull()) { throw new ArgumentNullException("cacheType", "请输入缓存类型"); } if (obj != null) { DateTime now = DateTime.Now; switch (objCacheFactor) { case CacheFactor.Minute: now = DateTime.Now.AddMinutes((double)numeral); break; case CacheFactor.Hour: now = DateTime.Now.AddHours((double)numeral); break; case CacheFactor.Day: now = DateTime.Now.AddDays((double)numeral); break; case CacheFactor.Max: now = DateTime.MaxValue; break; } lock (CacheLock) { string key = GetKey(cacheType, childKey); _cache.Remove(key); _cache.Insert(key, obj, cacheDependency, now, TimeSpan.Zero, priority, cacheItemRemovedCallback); } } }
public static void AddToCache(this object obj, string cacheType, string childKey, string fileName, CacheFactor objCacheFactor, int numeral, CacheItemRemovedCallback cacheItemRemovedCallback) { CacheDependency cacheDependency = new CacheDependency(fileName); obj.AddToCache(cacheType, childKey, cacheDependency, objCacheFactor, numeral, CacheItemPriority.Normal, cacheItemRemovedCallback); }
public static void AddToCache(this object obj, string cacheType, string childKey, CacheFactor objCacheFactor, int numeral, CacheItemRemovedCallback cacheItemRemovedCallback) { obj.AddToCache(cacheType, childKey, null, objCacheFactor, numeral, CacheItemPriority.Normal, cacheItemRemovedCallback); }
public static void AddToCache(this object obj, string cacheType, string childKey, CacheDependency dep, CacheFactor objCacheFactor, int numeral) { obj.AddToCache(cacheType, childKey, dep, objCacheFactor, numeral, CacheItemPriority.Normal, null); }
public static void AddToCache(this object obj, string cacheType, string childKey, CacheFactor objCacheFactor, int numeral, CacheItemPriority priority) { obj.AddToCache(cacheType, childKey, null, objCacheFactor, numeral, priority, null); }