Redis实战(五)
删除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();//删除全部数据