PHP Synchronization Scheme

Source: Internet
Author: User
Tags php source code
Introduction: This is the PHP synchronization scheme detailed page, introduced and php,php PHP synchronization program related knowledge, skills, experience, and some PHP source code and so on.

class= ' pingjiaf ' frameborder= ' 0 ' src= ' http://biancheng.dnbcw.info/pingjia.php?id=356624 ' scrolling= ' no ' > PHP synchronous execution is quite troublesome, according to the MySQL documentation, so to do.


===============================================================
Get_lock (Str,timeout)
Try to use string str given the name to get a lock, timeout to timeout seconds. If the lock is successfully obtained, 1 is returned, and if the operation times out it returns 0 (for example, because another client has blocked the name earlier), or null if an error occurs (such as a lack of memory or thread mysqladmin Kill is disconnected). If you have a lock that you get with Get_lock (), the lock will be lifted when you perform release_lock () or your connection is disconnected (normal or abnormal).

This function can be used to perform an application lock or an impersonation record lock. The name is locked within the server scope. If a name has been blocked by a client, Get_lock () will block any request from another client for blocking the same name. This allows the client to agree on a blockade name to use this name to work with the proposed lock. Be aware, however, that it also allows a client that is not in a group of cooperating clients to block the name, whether it is in service or unintentional, which prevents any client in cooperation from blocking the name. One way to reduce this situation is to use database-specific or application-specific block names. For example, use a block name in the form of db_name.str or APP_NAME.STR.


===============================================================

If a file does not want to be accessed concurrently by the user, it can only be accessed sequentially.

If a. PHP This file, do not want to be accessed at the same time by two requests, you can:

$db = Getdb ();//Get a database connection.

$db->query (' do Get_locak ');

Love EE focus on Java Michael Jackson Video station JSON online tool

Http://biancheng.dnbcw.info/php/356624.html Pageno:2
  • 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.