{"id":20962622,"url":"https://github.com/x-punch/x-locker","last_synced_at":"2025-06-11T21:06:30.811Z","repository":{"id":57530012,"uuid":"266739432","full_name":"x-punch/x-locker","owner":"x-punch","description":"Lock for golang, support monolithic application lock or distributed lock.","archived":false,"fork":false,"pushed_at":"2020-09-10T09:27:31.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T07:14:56.519Z","etag":null,"topics":["lock","mutex","mutex-lock","redlock","sync"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/x-punch.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-05-25T09:32:49.000Z","updated_at":"2020-09-10T09:26:46.000Z","dependencies_parsed_at":"2022-09-26T18:11:25.658Z","dependency_job_id":null,"html_url":"https://github.com/x-punch/x-locker","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/x-punch/x-locker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-punch%2Fx-locker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-punch%2Fx-locker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-punch%2Fx-locker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-punch%2Fx-locker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/x-punch","download_url":"https://codeload.github.com/x-punch/x-locker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-punch%2Fx-locker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259340623,"owners_count":22843026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["lock","mutex","mutex-lock","redlock","sync"],"created_at":"2024-11-19T02:35:49.010Z","updated_at":"2025-06-11T21:06:30.793Z","avatar_url":"https://github.com/x-punch.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# X Locker\nsync.Mutex can be used to lock in golang, but you need to define the mutex in advance.\nSometimes what we want to lock is generated dynamicly, so this package is used to lock in dynamic.\nWe can group some lock by id, and they shared the same mutex.\n\n## Usage\n```go\nimport locker \"github.com/x-punch/x-locker\"\n```\n```go\nl := locker.NewLocker()\n```\n```go\nl.Lock(\"id\")\ndefer l.Unlock(\"id\")\n// do something\n```\n\n# Redlock\nRedsync provides a Redis-based distributed mutual exclusion lock implementation for Go as described in [this post](http://redis.io/topics/distlock).\n\n## Usage\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/go-redis/redis/v8\"\n\t\"github.com/x-punch/x-locker/redlock\"\n)\n\nfunc main() {\n\tlocker := redlock.New([]redlock.RedisClient{redis.NewClient(\u0026redis.Options{Addr: \":6379\"})})\n\n\tl := locker.NewLock(\"id\")\n\tif err := l.Lock(); err != nil {\n\t\tpanic(err)\n\t}\n\tdefer l.Unlock()\n    \n    // do something\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-punch%2Fx-locker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fx-punch%2Fx-locker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-punch%2Fx-locker/lists"}