C # Redis Combat (V)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.