示例#1
0
文件: Cache.cs 项目: jeffora/Glimpse
        public override object GetData(ITabContext context)
        {
            var cacheModel = new CacheModel();
            cacheModel.Configuration.EffectivePercentagePhysicalMemoryLimit = HttpRuntime.Cache.EffectivePercentagePhysicalMemoryLimit;
            cacheModel.Configuration.EffectivePrivateBytesLimit = HttpRuntime.Cache.EffectivePrivateBytesLimit;

            var list = HttpRuntime.Cache.Cast<DictionaryEntry>().ToList();
            foreach (var item in list)
            {
                try
                {
                    var cacheEntry = MethodInfoCacheGet.Invoke(HttpRuntime.Cache, new object[] { item.Key, 1 });

                    var cacheItemModel = new CacheItemModel();
                    cacheItemModel.Key = item.Key.ToString();
                    cacheItemModel.Value = Serialization.GetValueSafe(item.Value);
                    cacheItemModel.CreatedOn = GetCacheProperty(ProcessInfoUtcCreated, cacheEntry) as DateTime?;
                    cacheItemModel.ExpiresOn = GetCacheProperty(ProcessInfoUtcExpires, cacheEntry) as DateTime?;
                    cacheItemModel.SlidingExpiration = GetCacheProperty(ProcessInfoSlidingExpiration, cacheEntry) as TimeSpan?;

                    cacheModel.CacheItems.Add(cacheItemModel);
                }
                catch (Exception)
                {
                    return false;
                }
            }

            return cacheModel;
        }
示例#2
0
文件: Cache.cs 项目: jnfsmile/Glimpse
        public override object GetData(ITabContext context)
        {
            var cacheModel = new CacheModel();
            var cacheEnumerator = HttpRuntime.Cache.GetEnumerator();
            cacheModel.Configuration.EffectivePercentagePhysicalMemoryLimit = HttpRuntime.Cache.EffectivePercentagePhysicalMemoryLimit;
            cacheModel.Configuration.EffectivePrivateBytesLimit = HttpRuntime.Cache.EffectivePrivateBytesLimit;

            while (cacheEnumerator.MoveNext())
            {
                var currentCacheEntry = cacheEnumerator.Entry;

                CacheItemModel cacheItemModel = null;
                if (TryGetCacheItemModel(currentCacheEntry, out cacheItemModel))
                {
                    cacheModel.CacheItems.Add(cacheItemModel);
                }
            }

            return cacheModel;
        }