예제 #1
0
파일: CacheManager.cs 프로젝트: vebin/soa
        /// <summary>
        /// 获取到缓存的统计信息
        /// </summary>
        /// <returns></returns>
        public List<CacheInfo> GetCacheStatic()
        {
            if (m_IsConnected)
            {
                Dictionary<String, CacheInfo> dictCacheInfo = new Dictionary<string, CacheInfo>();

                List<String> keys = m_RedisClient.SearchKeys("MBSOA:*");
                foreach (String item in keys)
                {
                    String[] keyArray = item.Split(":");
                    String serviceName = keyArray[1];
                    String methodName = GetMethodName(keyArray);
                    String dictKey = serviceName + "-" + methodName;

                    CacheInfo ci;
                    if (dictCacheInfo.ContainsKey(dictKey))
                        ci = dictCacheInfo[dictKey];
                    else
                    {
                        ci = new CacheInfo()
                        {
                            ServiceName = serviceName,
                            MethodName = methodName,
                            CacheKeyNum = 0
                        };
                        dictCacheInfo.Add(dictKey, ci);
                    }
                    ci.CacheKeyNum++;
                }

                return dictCacheInfo.Select(x => x.Value).ToList();
            }
            else
            {
                return null;
            }
        }