The Home for Magento 2 Excellence

Quality-tested Magento 2 modules. Explore. Evaluate. Elevate. #magento2

748 Modules
496 Ready
245 Need Help
🏆 Leaderboard
Popular Module Potentially Abandoned vv1.4.0

Magento2 Lock

snowio/magento2-lock

Provides a multi-server lock service, allowing developers to apply mutual exclusion locks to shared resources. Prevents simultaneous access to resources across multiple servers.

216,288
Downloads
Above average
7
GitHub Stars
Below average
5y ago
Last Release
1
Open Issues
Build Passing
Ready to install

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
18 warnings
L5 PHPStan

Tested on Magento 2.4.8-p4

Recent Test History

Each release is tested against the latest Magento version at that time.

vv1.4.0 on Magento 2.4.8-p4
Mar 22, 2026
vv1.4.0 on Magento 2.4.8-p3
Dec 27, 2025

Share This Module's Status

Magento2 Lock Magento compatibility status badge

README

Loaded from GitHub

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.

Prerequisites

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.

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

Attempt to obtain a lock ####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.

public LockService::releaseLock($lockName)

Release the lock

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

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.