Bulk Update memcached Cache

Source: Internet
Author: User

If there are 3 types of data in the system company,user,product

The effect of batch update cache is achieved by maintaining version number version

Memcache. ADD ("Company", Cversion); record the version of company data

Memcache. ADD ("User", uversion); record the version of the user data

Memcache. ADD ("Product", pversion); record the version of the product data

Maintain versions when updating or deleting data

Memcache. ADD ("Company", cversion+1);

Company+type+version is the key to get the data when querying the data

Key=memcache.get ("Company");

Memcache.get ("Company" +type+key);

         PublicIenumerable<company> GetList (intcount) {                        varVersion=distcache.get (" Company"); if(Version = =NULL) {Distcache.add (" Company",0); Version=0; }                     varKey ="Company_list_"+ Count +"_version"+version; varobj =Distcache.get (key); if(obj = =NULL)            {                vardata =_dal.                GetList (count); Distcache.add (Key, Jsonconvert.serializeobject (data),true); returndata; }            returnJsonconvert.deserializeobject<ienumerable<company>>(obj.                    ToString ()); }         Public intUpdatecompany (company info) {varVersion = Distcache.get (" Company"); if(Version = =NULL) {Distcache.add (" Company",0); Version=0; }            Else{version= Convert.ToInt32 (version) +1; Distcache.add (" Company", version); }            return_dal.        Update (info); }

Bulk Update memcached Cache

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.