Exemple #1
0
        //public bool Set(string key, object value)
        //{
        //    var cacheService = GetCacheService(key);
        //    if (cacheService == null) return false;

        //    CacheMetadata meta;
        //    if (!_Caches.TryGetValue(key, out meta))
        //    {
        //        cacheService.Set(new CacheEntry(meta, value));
        //        return true;
        //    }

        //    return false;
        //}

        /// <summary>
        /// 注册缓存
        /// </summary>
        /// <param name="cacheMetadata">缓存元数据信息,<see cref="CacheMetadata"/></param>
        public void Register(CacheMetadata cacheMetadata)
        {
            try
            {
                if (cacheMetadata == null)
                {
                    throw new ArgumentNullException("cacheMetadata");
                }
                _Caches.AddOrUpdate(cacheMetadata.Key, k => cacheMetadata, (k, v) => cacheMetadata);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
 internal CacheInfo(CacheMetadata meta, object value)
     : this(meta.Key, value, meta.SlidingExpiration, meta.AbsoluteExpiration)
 {
 }