File_put_contents high concurrency and exclusive locking

Source: Internet
Author: User
File_put_contents high concurrency and exclusive locking
This article introduces how to use file_put_contents in php to write data to null in high concurrency and exclusive locks. For more information, see.

During Highly Concurrent access, data is left blank when file_put_contents is used to write data to a file.

View the official documentation: int file_put_contents (string $ filename, string $ data [, int $ flags [, resource $ context])

Parameter: file name of the data to be written to filename.

The data to be written. The type can be string, array, or stream resources (as mentioned above ).

Flagsflags can be FILE_USE_INCLUDE_PATH, FILE_APPEND and/or LOCK_EX (to obtain an exclusive lock). However, be cautious when using FILE_USE_INCLUDE_PATH.

A context resource. An exclusive lock can be obtained directly until the flags parameter is LOCK_EX in high concurrency.

In addition, the flock function also provides the file locking method:

     

Note that flock () requires a file pointer.

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.