{"id":18753171,"url":"https://github.com/swordev/mutex-php","last_synced_at":"2026-06-17T16:01:56.237Z","repository":{"id":57063306,"uuid":"278839791","full_name":"swordev/mutex-php","owner":"swordev","description":null,"archived":false,"fork":false,"pushed_at":"2020-07-27T12:11:32.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-18T05:56:48.323Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swordev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-11T10:33:05.000Z","updated_at":"2022-04-11T08:36:22.000Z","dependencies_parsed_at":"2022-08-24T10:10:22.069Z","dependency_job_id":null,"html_url":"https://github.com/swordev/mutex-php","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/swordev/mutex-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swordev%2Fmutex-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swordev%2Fmutex-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swordev%2Fmutex-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swordev%2Fmutex-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swordev","download_url":"https://codeload.github.com/swordev/mutex-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swordev%2Fmutex-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34453446,"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-17T02:00:05.408Z","response_time":127,"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-07T17:24:35.879Z","updated_at":"2026-06-17T16:01:56.192Z","avatar_url":"https://github.com/swordev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mutex\n\u003e Read-write concurrency control\n\n## Installation\n\n```sh\ncomposer require @swordev/mutex\n```\n\n## Usage\n\n### File read/write lock\n\n```php\nuse Swordev\\Mutex\\FileMutex;\n\n$mutex1 = new FileMutex('key');\n$mutex2 = new FileMutex('key');\n\n$mutex1-\u003ereadLock(); // true\n$mutex2-\u003ewriteLock(); // false\n\n$mutex1-\u003eunlock(); // true\n$mutex2-\u003ewriteLock(); // true\n```\n\n### Timeout\n\n```php\nuse Swordev\\Mutex\\FileMutex;\n\n$mutex = new FileMutex('key');\n$mutex-\u003ewriteLock(5000);\n```\n\n### Contextual lock\n\n```php\nuse Swordev\\Mutex\\FileMutex;\n\nclass Foo {\n\tfunction method() {\n\t\t$mutex = new FileMutex(__CLASS__ . '|' . __FUNCTION__);\n\t\t$mutex-\u003ewriteLock();\n\t\t// ...\n\t}\n}\n```\n\n### Mutex factory\n\n```php\nuse Swordev\\Mutex\\MutexFactory;\n\n$mutex = new MutexFactory::create(FileMutex::class, 'key');\n```\n\n## Development\n\n### Test\n\n```sh\ncomposer run test\n```\n\n### Analyse\n\n```sh\ncomposer run analyse\n```\n\n## Author\n\nJuanra GM - https://github.com/juanrgm\n\nDistributed under the MIT license.\n\n[https://github.com/swordev/mutex-php](https://github.com/swordev/mutex-php)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswordev%2Fmutex-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswordev%2Fmutex-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswordev%2Fmutex-php/lists"}