Memocache
http://blog.csdn.net/zhoufoxcn/article/details/6282099 http://blog.csdn.net/dinglang_2009/article/details/6917794 public void TestMemcache() { var list = new List<MktPriceMarketData>(); var Dao = (Framework.IService.ICommonService)ctx["CommonService"]; var list1 = Dao.ExecuteRowMapper(new Framework.QueryInfo() { CustomSQL = "select * from mkt_price_market_data" }, new MktPriceMarketData()).ToList(); for (int i = 0; i < 3; i++) { list1.AddRange(list1); } MemcachedClient client = new MemcachedClient(); //初始化服务器和端口 string[] servers = { "127.0.0.1:11211" }; //初始化连接池 SockIOPool pool = SockIOPool.GetInstance(); pool.SetServers(servers); pool.InitConnections = 3; pool.MinConnections = 3; pool.MaxConnections = 5; pool.SocketConnectTimeout = 1000; pool.SocketTimeout = 3000; pool.MaintenanceSleep = 30; //故障转移 pool.Failover = true; pool.Nagle = false; pool.Initialize(); //客户端实例 MemcachedClient mc = new MemcachedClient(); mc.EnableCompression = false; mc.Add("kxb", "柯相彬"); mc.Add("kxq", "my name is kxq"); int pageSize = 1000; int total = list1.Count; int pages = ((total - 1) / pageSize) + 1; Parallel.For(1, 100, i => { var objList = list1.Skip((i - 1) * pageSize).Take(pageSize).ToList(); string key = "m" + i; mc.Delete(key); mc.Add(key, objList); }); var list3 = new ConcurrentBag<MktPriceMarketData>(); Parallel.For(1, 100, i => { string key = "m" + i; var kuai = (List<MktPriceMarketData>)mc.Get(key); Parallel.ForEach(kuai, item => { list3.Add(item); }); }); }