码迷,mamicode.com
首页 > 其他好文 > 详细

Redis实战(五)

时间:2016-04-26 12:33:58      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

删除Redis中数据

                using (var redisClient = RedisManager.GetClient())
                {
                    var user = redisClient.GetTypedClient<User>();
                    var newUser = new User
                    {
                        Id = user.GetAll().Count,
                        Name = txtName.Text,
                        Job = new Job { Position = txtPosition.Text }
                    };
                    user.Delete(newUser);

                }

 

2、void DeleteById(object id);删除数据函数

 

using (var redisClient = RedisManager.GetClient())
                {
                    var user = redisClient.GetTypedClient<User>();
                    //var newUser = new User
                    //{
                    //    Id = user.GetAll().Count,
                    //    Name = txtName.Text,
                    //    Job = new Job { Position = txtPosition.Text }
                    //};
                    //user.Delete(newUser);
                    user.DeleteById(txtRedisId.Text);//txtRedisId.Text中为ID值
}

 

3、void DeleteByIds(IEnumerable ids);批量删除函数

                using (var redisClient = RedisManager.GetClient())
                {
                    var user = redisClient.GetTypedClient<User>();
                    user.DeleteByIds((txtRedisId.Text).ToList());//txtRedisId.Text中为ID值

                }

4、void DeleteAll();删除全部数据

 

var user = redisClient.GetTypedClient<User>();
                    user.DeleteAll();//删除全部数据

 

Redis实战(五)

标签:

原文地址:http://www.cnblogs.com/wuxl360/p/5434371.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!