protected void btnSetValue_Click(object sender, EventArgs e) { using (var redisClient = RedisManager.GetClient()) { var user = redisClient.GetTypedClient <User>(); if (user.GetAll().Count > 0) { var htmlStr = string.Empty; foreach (var u in user.GetAll()) { htmlStr += "<li>ID=" + u.Id + " 姓名:" + u.Name + " 所在部门:" + u.Job.Position + "</li>"; } lblPeople.Text = htmlStr; } lblShow.Text = "目前共有:" + user.GetAll().Count.ToString() + "人!"; } }
static void Main(string[] args) { #region 封装调用 //HashOperator operate = new HashOperator(); //operate.Set("rj", "renjing", "任静"); //var rj = operate.Get<string>("rj", "renjing"); #endregion IRedisClient redisClient = RedisManager.GetClient(); string renjing = "renjing"; redisClient.Set("renjing", renjing); string getV = redisClient.Get <string>("renjing"); Console.Read(); }
protected void btnSearch_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtScreenPosition.Text)) { using (var redisClient = RedisManager.GetClient()) { var user = redisClient.GetTypedClient <User>(); var userList = user.GetAll().Where(x => x.Job.Position.Contains(txtScreenPosition.Text)).ToList(); if (userList.Count > 0) { var htmlStr = string.Empty; foreach (var u in userList) { htmlStr += "<li>ID=" + u.Id + " 姓名:" + u.Name + " 所在部门:" + u.Job.Position + "</li>"; } lblPeople.Text = htmlStr; } lblShow.Text = "筛选后共有:" + userList.Count.ToString() + "人!"; } } }
static RedisBase() { Core = RedisManager.GetClient(); }