wpdesk/wp-mutex

Library for locking in Wordpress.

1.1 2018-11-13 12:27 UTC

This package is auto-updated.

Last update: 2024-04-14 02:08:03 UTC


README

pipeline status coverage report Latest Stable Version Total Downloads Latest Unstable Version License

wpdesk/wp-lock

wp-mutex is a simple library for WordPress plugins to help executing critical code in concurrent situations.

Requirements

PHP 5.5 or later.

Composer

You can install the bindings via Composer. Run the following command:

composer require wpdesk/wp-mutex

To use the bindings, use Composer's autoload:

require_once 'vendor/autoload.php';

Manual installation

If you do not wish to use Composer, you can download the latest release. Then, to use the Notices, include the init.php file.

require_once('/path/to/notice/src/init.php');

Getting Started

Simple usage looks like:

$lock_name = 'my_lock_name';
if ( wpdesk_acquire_lock( $lock_name ) ) {
    // do critical stuff
    wpdesk_release_lock( $lock_name );
} else {
    echo 'Unable to acquire lock!';
}

Project documentation

PHPDoc: https://wpdesk.gitlab.io/wp-mutex/index.html