什么是PHP中的C#lock语句? [英] What is equivalent of the C# lock statement in PHP?

查看:117
本文介绍了什么是PHP中的C#lock语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于并发和确保数据的完整性,您将如何获得给定对象的互斥锁定?

For concurrency and ensuring the integrity of the data, how would you obtain a mutual-exclusion lock for a given object? Would you need to use locking within the database, or a file, or does PHP support something like this?

推荐答案

PHP不会在数据库或文件中使用锁定, t支持多线程,因此没有对象的锁定机制。如果您要锁定文件,可以使用羊群。没有必要锁定数据库,因为数据库引擎通常可以处理多个连接。

PHP doesn't support multithreading so there's no locking mechanism for objects. If you want to lock a file you could use flock for that. There's no need to lock database as database engines usually can handle multiple connections.

这篇关于什么是PHP中的C#lock语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆