Ejemplo n.º 1
0
        /// <summary>
        /// 获取内存缓存
        /// </summary>
        /// <param name="cacheKey"></param>
        /// <returns></returns>
        public static object Get(string cacheKey)
        {
            //如果正在垃圾回收,请等待
            while (isGcing)
            {
                Thread.Sleep(10);
            }

            if (!_cacheDictionary.ContainsKey(cacheKey))
            {
                return(null);
            }

            CacheUnit unit = (CacheUnit)_cacheDictionary[cacheKey];

            if (unit != null && unit.IsEnabled())
            {
                return(unit.Data);
            }

            _cacheDictionary.Remove(cacheKey);
            return(null);
        }