/// <summary> /// 根据key返回基本信息 /// </summary> /// <param name="key">key</param> /// <returns></returns> /// <remarks>2013-8-13 黄志勇 添加</remarks> public SyKeyInfo GetNetKeyInfo(string key) { SyKeyInfo info = null; var value = MemoryProvider.Default.Get <object>(key); if (value != null) { info = new SyKeyInfo(); info.Key = key; //var item = (Keys)Enum.Parse(typeof(Keys), key); //info.Desc = item.GetDescription(); info.MemoryUsed = FormatUtil.FormatByteCount(DataUtil.ObjectSize(value)); if (IsList(value)) { var isArray = value.GetType().IsArray; info.KeyType = isArray ? "数组" : "列表"; info.Count = GetItemCount(value); info.KeyValue = Hyt.Util.Serialization.JsonUtil.ToJson(value); info.CanShow = !isArray && CanShow(key, "netKey") && info.Count > 0; } else { info.KeyType = value.GetType().Name; info.KeyValue = value.ToString(); } } return(info); }
/// <summary> /// 根据key返回基本信息 /// </summary> /// <param name="key">key</param> /// <returns></returns> /// <remarks>2013-8-13 黄志勇 添加</remarks> public SyKeyInfo GetMemcacheKeyInfo(string key) { SyKeyInfo info = null; var value = CacheManager.Instance.Get <object>(key); if (value != null) { info = new SyKeyInfo(); info.Key = key; var index = key.IndexOf('_'); var prefix = index < 0 ? key : key.Substring(0, index + 1); var item = (CacheKeys.Items)Enum.Parse(typeof(CacheKeys.Items), prefix); info.Desc = item.GetDescription(); info.MemoryUsed = FormatUtil.FormatByteCount(DataUtil.ObjectSize(value)); if (IsList(value)) { var isArray = value.GetType().IsArray; info.KeyType = isArray ? "数组" : "列表"; info.Count = GetItemCount(value); info.KeyValue = Hyt.Util.Serialization.JsonUtil.ToJson(value); info.CanShow = !isArray && CanShow(key, "memcached") && info.Count > 0; } else { info.KeyType = value.GetType().Name; info.KeyValue = (value is DateTime)?((DateTime)value).ToString("yyyy-MM-dd HH:mm:ss"):value.ToString(); } } return(info); }