Exemplo n.º 1
0
        public string SetList(string key, string value)
        {
            string result = "success";

            try
            {
                DoRedisList rl = new DoRedisList();
                rl.Add(key, value, DateTime.Now.AddMinutes(2));
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result);
        }
Exemplo n.º 2
0
        public string GetList(string key)
        {
            string result = "";

            try
            {
                DoRedisList   rl    = new DoRedisList();
                List <string> liStr = rl.Get(key);
                if (liStr == null)
                {
                    SetList(key, "tom");
                }
                liStr  = rl.Get(key);
                result = string.Join(",", liStr);
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result);
        }
Exemplo n.º 3
0
        //
        // GET: /RedisTest/
        public ActionResult Index()
        {
            string key = "zlh";

            //清空数据库
            DoRedisBase.Core.FlushAll();
            //给list赋值
            DoRedisBase.Core.PushItemToList(key, "1");
            DoRedisBase.Core.PushItemToList(key, "2");
            DoRedisBase.Core.AddItemToList(key, "3");
            DoRedisBase.Core.PrependItemToList(key, "0");
            DoRedisBase.Core.AddRangeToList(key, new List <string>()
            {
                "4", "5", "6"
            });
            #region 阻塞
            //启用一个线程来处理阻塞的数据集合
            //  new Thread(new ThreadStart(RunBlock)).Start();
            var list = new DoRedisList().Get(key);
            #endregion
            //   Console.ReadKey();
            return(Json(list, JsonRequestBehavior.AllowGet));
        }