public void MultiGetDemo() { List <string> personNameList = new List <string>(); for (int i = 0; i < 10; i++) { personNameList.Add("李刚00" + i); } //批量获取,只通过一次网络通讯就取回所有personNameList中的指定的所有数据 IDictionary <string, object> resultList = DataCatch.GetCache(personNameList); PerSon person; foreach (KeyValuePair <string, object> item in resultList) { person = item.Value as PerSon; if (person != null) { Console.WriteLine("取回[{0}]的结果——UserId:{1},UserName:{2}", "李刚", person.UserId, person.UserName); } else { Console.WriteLine("取回[{0}]失败!", "李刚"); } } }
public void GetDemo() { PerSon person = DataCatch.GetCache <PerSon>("李刚"); if (person != null) { Console.WriteLine("取回[{0}]的结果——UserId:{1},UserName:{2}", "李刚", person.UserId, person.UserName); } else { Console.WriteLine("取回[{0}]失败!", "李刚"); } }