public bool Set(string key, object value, DateTime absoluteExpiration, string groupName = null) { if (key == null || value == null) { return(false); } var policy = new CacheItemPolicy(); policy.Priority = CacheItemPriority.Default; policy.AbsoluteExpiration = absoluteExpiration; if (groupName != null) { policy.RemovedCallback += a => { LocalCacheKeyStorage.RemoveByKey(a.CacheItem.Key); }; } s_Cache.Set(new CacheItem(key, value), policy); if (groupName != null) { LocalCacheKeyStorage.Set(key, groupName); } return(true); }
public bool Set(string key, object value, string groupName = null) { if (key == null || value == null) { return false; } var policy = new CacheItemPolicy(); policy.Priority = CacheItemPriority.NotRemovable; if (groupName != null) { policy.RemovedCallback += a => { LocalCacheKeyStorage.RemoveByKey(a.CacheItem.Key); }; } s_Cache.Set(new CacheItem(key, value), policy); if (groupName != null) { LocalCacheKeyStorage.Set(key, groupName); } return true; }
public List<string> GetKeysByGroup(string groupName) { return LocalCacheKeyStorage.GetKeys(groupName); }