Use the increment () | decrement () Operation Summary of the memcached provider Client

Source: Internet
Author: User

Use the memcached provider client to perform the increment | decrement () operation:

1. During store, only int numbers of string type can be properly stored in increment and decrement; otherwise (increment \ decrement), return-1.

Failed:

 
This. Cache. Add ("Num1",100); // String should be input here.LongNewnum =This. Cache. increment ("Num1",1); // Failed, return-1

Successful:

 
This. Cache. Add ("Num1","100");LongNewnum =This. Cache. increment ("Num1",1); // Success, 101 is returned

 

2. In increment and decrement, if the key does not exist, the value is smaller than 0, and the value is not an integer,-1 is returned.

Increment and decrement are thread-safe.

 

3. In decrement, if the value is 0, the value is always 0 and will not decrease.

 

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.