private void loadCacheItem <T>(DAO dao, String cacheName, String methodName, String keyName) where T : BASEBean { try { var connectorCache = new Cache(cacheName); MethodInfo method = dao.GetType().GetMethod(methodName); var list = (List <T>)method.Invoke(dao, null); foreach (T item in list) { connectorCache.addCacheItem(item.FieldMap[keyName].ToString(), item); } if (!cacheMap.ContainsKey(connectorCache.Name)) { cacheMap.Add(connectorCache.Name, connectorCache); } else { LogManager.Warn(string.Format("Duplicate cache name: \"{0}\" found and ignored", connectorCache.Name)); } } catch (Exception e) { LogManager.Error(e); } }
/** * Adds a new Cache item to the cache. * @param key - key value for the data provided * @param data - BASEBean data bean * @see BASEBean */ public void addCacheItem(String key, BASEBean data) { if (!cacheMap.ContainsKey(key)) { cacheMap.Add(key, data); } else { LogManager.Warn(string.Format("Cache \"{0}\" - Item Key \"{1}\" already exists - ignoring key", this.Name, key)); } }