php-locking:PHP 进程同步

时间:2021-06-02 08:24:45
【文件属性】:
文件名称:php-locking:PHP 进程同步
文件大小:8KB
文件格式:ZIP
更新时间:2021-06-02 08:24:45
PHP PHP 自旋锁 使用 PHP 避免竞争条件? 想在 PHP 中使用自旋锁来保护关键代码路径不被多个进程并行执行吗? 使用这个库! 为什么? 我经常看到的一个常见竞争条件是问题。 它是在检查和使用资源在不同的步骤中完成时创建的,另一个进程可能会在检查和使用之间更改资源。 例如:您有一个购物篮系统,其中一个客户可能只有一个购物篮。 要获得篮子(包括“延迟初始化”),您可以执行以下操作: class BasketManager { public function getBasketForCustomer ( Customer $ customer ) { $ currentBasket = $ this -> basketRepository -> getBasketForCustomer ( $ customer ); if ( $ currentBasket ) {
【文件预览】:
php-locking-master
----src()
--------SpinlockInterface.php(604B)
--------SpinlockFactoryInterface.php(321B)
--------MemcacheSpinlock()
--------SpinlockException.php(159B)
----CONTRIBUTING.md(834B)
----LICENSE(1KB)
----README.md(5KB)
----.editorconfig(603B)
----composer.json(560B)

网友评论