2017 © Pedro Peláez
 

magento2-module magento2-lock

A Magento 2 module which provides a multi-server lock service

image

snowio/magento2-lock

A Magento 2 module which provides a multi-server lock service

  • Wednesday, September 13, 2017
  • by joshdifabio
  • Repository
  • 3 Watchers
  • 2 Stars
  • 28,565 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 5 Versions
  • 15 % Grown

The README.md

Magento 2 Lock

Description

A Magento 2 module which provides a multi-server lock service. This allows developers to apply mutual exclusion locks to shared resources so that they are not accessed simultaneously., (*1)

Prerequisites

  • PHP 7.0 or newer.
  • magento/framework module 100 or newer.
  • Composer (https://getcomposer.org/download/).

Installation

composer require snowio/magento2-lock
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:flush

Usage

The lock service can be accessed through dependency injection. Please refer the dependency injection section of the Magento DevDocs for more information on how to use dependency injection., (*2)

public boolean LockService::acquireLock(string $name, int $timeout)

Attempt to obtain a lock, (*3)

Parameters

  • $lockName : The lock identifier/name
  • $timeout : Lock timeout. A negative timeout implies an infinite timeout.

Return Values

A boolean indicating if the the lock was acquired., (*4)

public LockService::releaseLock($lockName)

Release the lock, (*5)

Parameters

  • $lockName : The lock identifier/name

Example

namespace Vendor\Module\Model\Accessors;
class ResourceAccessor
{
    private $lockService;

    public function __construct(
        SnowIO\Lock\Api\LockService $lockService
    ) {
        $this->lockService = $lockService    
    }

    public function access($resource)
    {
        $lockName = //.. resource lock name

        //try acquire the lock
        if (!$this->lockService->acquireLock($lockName, 0)) {
            //Lock was not acquired ...
        }
        //Lock was acquired 

        try {
            // Process $resource 
        } finally {
            //release the lock
            $this->lockService->releaseLock($lockName);
        }

    }
}

Applications

License

This software is licensed under the MIT License. View the license, (*6)

The Versions

13/09 2017

dev-master

9999999-dev

A Magento 2 module which provides a multi-server lock service

  Sources   Download

MIT

The Requires

  • php >=7
  • magento/framework ^100|^101

 

by Josh Di Fabio
by Alexander Wanyoike

13/09 2017

v1.2.0

1.2.0.0

A Magento 2 module which provides a multi-server lock service

  Sources   Download

MIT

The Requires

  • php >=7
  • magento/framework ^100|^101

 

by Josh Di Fabio
by Alexander Wanyoike

17/02 2017

v1.1.0

1.1.0.0

A Magento 2 module which provides a multi-server lock service

  Sources   Download

MIT

The Requires

  • php >=7
  • magento/framework ^100

 

by Josh Di Fabio
by Alexander Wanyoike

10/02 2017

dev-feature/update-readme

dev-feature/update-readme

A Magento 2 module which provides a multi-server lock service

  Sources   Download

MIT

The Requires

  • php >=7
  • magento/framework ^100

 

by Alexander Wanyoike

25/10 2016

v1.0.0

1.0.0.0

A Magento 2 module which provides a multi-server lock service

  Sources   Download

MIT

The Requires

  • php >=7
  • magento/framework ^100

 

by Alexander Wanyoike