/// <summary> /// 添加购物车 /// </summary> /// <param name="OpenId">用户主键</param> /// <param name="Menu_Id"></param> /// <returns></returns> public int AddCar(string OpenId, int Menu_Id) { tb_Menu model = menuList.Where(s => s.M_Id == Menu_Id).FirstOrDefault(); //获取该用户的购物车缓存 List <tb_Menu> _menuList = _client.Get <List <tb_Menu> >(OpenId); if (_menuList != null) { tb_Menu m = _menuList.Where(s => s.M_Id == Menu_Id).FirstOrDefault(); if (m != null) { model.CarNum += 1; } else { model.CarNum = 1; _menuList.Add(model); } } else { _menuList = new List <tb_Menu>(); model.CarNum = 1; _menuList.Add(model); } _client.Set(OpenId, _menuList); return(_menuList.Count); }
public void SentinelInit() { var csredis = new CSRedis.CSRedisClient("mymaster,password=123", new[] { "192.169.1.10:26379", "192.169.1.11:26379", "192.169.1.12:26379" }); csredis.Set("test", DateTime.Now.ToString()); csredis.Get("test"); }
public void ClusterDbInit() { var csredis = new CSRedis.CSRedisClient(null, "127.0.0.1:6371,password=123,defaultDatabase=11,poolsize=10,ssl=false,writeBuffer=10240", "127.0.0.1:6372,password=123,defaultDatabase=12,poolsize=11,ssl=false,writeBuffer=10240", "127.0.0.1:6373,password=123,defaultDatabase=13,poolsize=12,ssl=false,writeBuffer=10240", "127.0.0.1:6374,password=123,defaultDatabase=14,poolsize=13,ssl=false,writeBuffer=10240"); csredis.Set("test", DateTime.Now.ToString()); csredis.Get("test"); }
public string get(string key) { return(_redis.Get(key)); }