V. Delete data in C # Redis Combat (iv), which describes how to write Key-value data in Redis, this article explains how to delete data from Redis.
1. Void Delete (T entity) and the use of delete function
using (var redisclient = redismanager.getclient ()) { var user = Redisclient.gettypedclient<user>(); var New User { = user. GetAll (). Count, = txtname.text, new Job {Position = txtposition.text} }; User. Delete (NewUser); }
The above code directly deletes the last piece of data, as follows:
2
, void Deletebyid (object id), delete data function
using(varRedisclient =redismanager.getclient ()) { varuser = 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);//ID value in Txtredisid.text}
For example, a piece of data with ID equal to 3 is deleted.
3, void Deletebyids (IEnumerable IDs); bulk Delete function
using (var redisclient = redismanager.getclient ()) { var user = Redisclient.gettypedclient<user>(); User. Deletebyids ((Txtredisid.text). ToList ()); // ID value in Txtredisid.text }
For example, the code removes three data with IDs: 1, 2, 6, respectively.
4
, void DeleteAll (); Delete all data
var user = Redisclient.gettypedclient<user>(); User. DeleteAll (); //
If you want to reprint, please specify the source, this series of blog sample program
http://blog.csdn.net/qiujialongjjj/article/details/17262851
C # Redis Combat (V)