Algorithm-how does php generate a unique incremental number?

Source: Internet
Author: User
1. method 2 of using the MySQL auto-increment field is not accepted. in high concurrency, make sure that the unique increment is 3. using C language to compile PHP extensions does not count first. Thank you! 1. the method of using the MySQL auto-increment field is not accepted.
2. Ensure high concurrency Unique Increment
3. Using C language to write PHP extensions is not counted

Thank you!

Reply content:

1. Do not accept the use of MySQL auto-increment Fields
2. Ensure high concurrencyUnique Increment
3. Using C language to write PHP extensions is not counted

Thank you!

Refer to the ObjectID algorithm of MongoDB. You can consider including the following parts in the ID to prevent conflicts.

  • Machine hash (preventing ID conflicts between multiple machines)
  • Process ID (preventing multi-process conflicts)
  • Timestamp (SEC)
  • Auto-increment value (auto-increment in the same second)

Putting the time at the most meeting can achieve a basically increasing effect

UUID1 effect similar, PHP has ready-made implementation of https://github.com/ramsey/uuid

Incremental. please sort the requests.

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.