tp5er/think-lock

thinkphp lock

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/tp5er/think-lock

dev-main 2024-05-06 07:58 UTC

This package is auto-updated.

Last update: 2025-10-06 11:12:01 UTC


README

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 文档