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);
        }
Example #2
0
        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;
        }
Example #3
0
 public List<string> GetKeysByGroup(string groupName)
 {
     return LocalCacheKeyStorage.GetKeys(groupName);
 }