Пример #1
0
        /// <summary>
        /// 多线程访问redis客户端
        /// </summary>
        static void ThreadTest()
        {
            Thread[] threads = new Thread[10];
            int      index   = 0;

            for (int i = 0; i < 10; i++)
            {
                index++;
                threads[i] = new Thread(() => StringRedisHelper.Set(index.ToString(), "线程" + index));
                Console.WriteLine(index.ToString() + ":" + index + "写入成功");
            }

            for (int i = 0; i < 10; i++)
            {
                threads[i].Start();
            }
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("取出" + i + "为:" + StringRedisHelper.Get(i.ToString()));
            }

            //from th in threads
            //select ()=> { index++;
            //    th = new Thread(() => StringRedisHelper.Set(index.ToString(), "线程" + index));}(

            //);
        }
Пример #2
0
 static void TestRedis()
 {
     StringRedisHelper.Set("test", "测试");
     Console.WriteLine(StringRedisHelper.Get("test"));
     //RedisManager.Instance.GetDatabase().StringSet("test", "ceshi1");
     //if(RedisManager.Instance.GetDatabase().KeyExists("test"))
     //Console.WriteLine(RedisManager.Instance.GetDatabase().StringGet("test"));
 }
Пример #3
0
        /// <summary>
        /// 在发送短信之后执行
        ///  步骤五:
        ///  创建短信内容至数据库 
        ///  创建发送记录至数据库
        /// (此处应放在SMSFactory.SendMsg或写在JobInstance中的SendJob.Exceuted)
        /// </summary>
        /// <param name="model"></param>
        /// <param name="receive"></param>
        /// <param name="list_phones"></param>
        /// <param name="redis_list_id">redis中保存的list的key</param>
        /// <param name="redis_expirationDate">redis中保存集合的过期时间(默认72小时)</param>
        /// <returns></returns>
        public bool AfterSend(PMS.Model.ViewModel.ViewModel_Message model, SMSModel_Receive receive, List<string> list_phones,string redis_list_id,int redis_expirationDate=72)
        {
            //5 将发送的短信以及提交响应存入SMSContent
            var mid = model.SMSMissionID;
            var uid = model.UID;
            bool isSaveMsgOk = smsContentBLL.SaveMsg(receive, model.Content, mid, uid);

            //在current表中存入发送信息,在query之前,表中的StatusCode默认为98,DescContent默认为"暂时未收到查询回执"
            //7月28日 注意此处已修改方法为:CreateReceieveMsg!!!
            if (!smsRecord_CurrentBLL.CreateReceieveMsg(receive.msgid, list_phones))
            {
                return false;
            }

            /*步骤六:
                    写入redis缓存中
                    (此处应放在SMSFactory.SendMsg中或写在JobInstance中的SendJob.Exceuted)
            */
            ListReidsHelper<PMS.Model.QueryModel.Redis_SMSContent> redisListhelper = new ListReidsHelper<PMS.Model.QueryModel.Redis_SMSContent>(redis_list_id);

            StringRedisHelper redisStrhelper = new StringRedisHelper();
            redisStrhelper.Set(receive.msgid, "1", DateTime.Now.AddMinutes(redis_expirationDate));
            return true;
        }