예제 #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
        private bool TryGetCacheItemModel(DictionaryEntry currentCacheEntry, out CacheItemModel cacheItemModel)
        {
            cacheItemModel = new CacheItemModel();
            object cacheEntry;

            try
            {
                cacheEntry = MethodInfoCacheGet.Invoke(HttpRuntime.Cache, new object[] { currentCacheEntry.Key, 1 });

                cacheItemModel.Key = currentCacheEntry.Key.ToString();
                cacheItemModel.Value = Serialization.GetValueSafe(currentCacheEntry.Value);
                cacheItemModel.CreatedOn = GetCacheProperty(ProcessInfoUtcCreated, cacheEntry) as DateTime?;
                cacheItemModel.ExpiresOn = GetCacheProperty(ProcessInfoUtcExpires, cacheEntry) as DateTime?;

                cacheItemModel.SlidingExpiration = GetCacheProperty(ProcessInfoSlidingExpiration, cacheEntry) as TimeSpan?;
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }