{"id":19001728,"url":"https://github.com/ledccn/webman_plugin_locker","last_synced_at":"2026-06-20T04:01:57.079Z","repository":{"id":184228422,"uuid":"671536108","full_name":"ledccn/webman_plugin_locker","owner":"ledccn","description":"Webman plugin ledc/locker","archived":false,"fork":false,"pushed_at":"2025-07-30T13:58:42.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T09:15:44.389Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ledccn.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-07-27T14:40:51.000Z","updated_at":"2025-07-30T13:57:48.000Z","dependencies_parsed_at":"2024-11-08T18:12:37.540Z","dependency_job_id":"32dcc9fa-fb31-4199-ba65-d93c0faefea0","html_url":"https://github.com/ledccn/webman_plugin_locker","commit_stats":null,"previous_names":["ledccn/webman_plugin_locker"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/ledccn/webman_plugin_locker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fwebman_plugin_locker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fwebman_plugin_locker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fwebman_plugin_locker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fwebman_plugin_locker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ledccn","download_url":"https://codeload.github.com/ledccn/webman_plugin_locker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ledccn%2Fwebman_plugin_locker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34556495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T18:12:29.981Z","updated_at":"2026-06-20T04:01:57.059Z","avatar_url":"https://github.com/ledccn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 介绍\n\nsymfony/lock for webman\n\n在 webman 中简化使用业务锁功能\n\n解决以下问题：\n\n - 并发业务操作有时候需要锁来防止并发导致的数据插入或更新问题\n - 单独使用 symfony/lock 时一般使用 $factory-\u003ecreateLock('key')，此时 key 是一个字符串，不利于后期维护或多处使用\n\n\n\n## 安装\n\n`compoer require ledc/locker`\n\n\n\n## 使用\n\n### 定义一个自己的 Locker 类\n\n比如：`support\\facade\\Locker.php`，继承 `Ledc\\Locker`\n\n然后在类上方加入注释（用于代码提示），举例如下：\n\n```php\n\u003c?php\n\nnamespace support\\facade;\n\nuse Symfony\\Component\\Lock\\LockInterface;\n\n/**\n * @method static LockInterface order(?string $orderId = null, ?float $ttl = null, ?bool $autoRelease = null, ?string $prefix = null)\n * @method static LockInterface changeCash(?string $userId = null, ?float $ttl = null, ?bool $autoRelease = null, ?string $prefix = null)\n */\nclass Locker extends \\Ledc\\Locker\n{\n}\n```\n\n### 业务中使用\n\n```php\n\u003c?php\n\nnamespace app\\controller;\n\nuse support\\facade\\Locker;\n\nclass User {\n    public function changeCash()\n    {\n        $lock = Locker::changeCash($currentUserId, 5, true);\n        if (!$lock-\u003eacquire()) {\n            throw new \\Exception('操作太频繁，请稍后再试');\n        }\n        try {\n            // 修改用户金额\n        } finally {\n            $lock-\u003erelease();\n        }\n\n        return 'ok';\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fledccn%2Fwebman_plugin_locker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fledccn%2Fwebman_plugin_locker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fledccn%2Fwebman_plugin_locker/lists"}