New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

tp5er/think-lock

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tp5er/think-lock

thinkphp lock

Source
Packagist
Version
dev-main
Version published
Maintainers
1
Created
Source

安装

composer require tp5er/think-lock

使用

<?php

namespace app\controller;

use app\BaseController;
use tp5er\think\lock\facade\Locker;

class Index extends BaseController
{
    public function index()
    {
        $lock = Locker::lock("index");
        if (!$lock->acquire()) {
            throw new \Exception('操作太频繁,请稍后再试');
        }
        try {
            //TODO 业务操作
        } finally {
            $lock->release();
        }
    }
}

更多操作参考:symfony/lock 文档

FAQs

Package last updated on 06 May 2024

Related posts