{"id":37225220,"url":"https://github.com/ggicci/distlock","last_synced_at":"2026-01-15T01:46:10.887Z","repository":{"id":57642399,"uuid":"258732154","full_name":"ggicci/distlock","owner":"ggicci","description":":lock: Simple Distributed Locks in Go using Redis, MySQL, PostgreSQL, MongoDB, etc.","archived":false,"fork":false,"pushed_at":"2024-11-25T19:07:49.000Z","size":48,"stargazers_count":38,"open_issues_count":5,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-14T20:45:17.456Z","etag":null,"topics":["distributed-lock","distributed-mutex","go","go-mongo-mutex","go-redis-lock","go-redis-mutex","go-sql-mutex","mutex","named-lock"],"latest_commit_sha":null,"homepage":"","language":"Go","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/ggicci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-04-25T09:22:44.000Z","updated_at":"2024-11-21T07:07:01.000Z","dependencies_parsed_at":"2024-04-14T06:22:36.544Z","dependency_job_id":"66d7d956-fde6-4dce-8528-fdfb8efe5345","html_url":"https://github.com/ggicci/distlock","commit_stats":null,"previous_names":["ggicci/go-redis-mutex"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ggicci/distlock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggicci%2Fdistlock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggicci%2Fdistlock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggicci%2Fdistlock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggicci%2Fdistlock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ggicci","download_url":"https://codeload.github.com/ggicci/distlock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggicci%2Fdistlock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28441031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:55:22.719Z","status":"ssl_error","status_checked_at":"2026-01-15T00:55:20.945Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["distributed-lock","distributed-mutex","go","go-mongo-mutex","go-redis-lock","go-redis-mutex","go-sql-mutex","mutex","named-lock"],"created_at":"2026-01-15T01:46:10.222Z","updated_at":"2026-01-15T01:46:10.879Z","avatar_url":"https://github.com/ggicci.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# distlock\n\n[![Go](https://github.com/ggicci/distlock/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/ggicci/distlock/actions/workflows/go.yml) [![codecov](https://codecov.io/gh/ggicci/distlock/branch/main/graph/badge.svg?token=2MDBW1V2TI)](https://codecov.io/gh/ggicci/distlock) [![Go Reference](https://pkg.go.dev/badge/github.com/ggicci/distlock.svg)](https://pkg.go.dev/github.com/ggicci/distlock)\n\n\u003cdiv align=\"center\"\u003e\n   Simple \u003cb\u003eDistributed Locks\u003c/b\u003e implementation in Go\n   \u003cdiv\u003ebacked on\u003c/div\u003e\n   \u003cdiv\u003eRedis, MySQL, PostgreSQL, MongoDB etc.\u003c/div\u003e\n\u003c/div\u003e\n\n## Features\n\n1. Namespace (names in the same namespace are unique, default namespace is `\"default\"`)\n2. Auto/No expiration (auto-released after a specific time or never expire)\n3. Support multiple backends:\n   - [x] Redis\n   - [x] MySQL\n   - [x] PostgreSQL\n   - [ ] MongoDB\n\n## Usage\n\n```go\nimport (\n    \"github.com/ggicci/distlock\"\n    \"github.com/gomodule/redigo/redis\"\n)\n\nvar redisPool = \u0026redis.Pool{\n    // ... configure your redis client\n}\n\nvar heavyRequestsGuard = distlock.New(\n    distlock.NewRedisProvider(redisPool),\n    distlock.WithNamespace(\"heavy_requests\"),\n    distlock.WithLockLifetime(10 * time.Second), // lifetime: 10s\n)\n\nuser := session.CurrentUser()\nmu := heavyRequestsGuard.New(\n    user.Username,\n    WithLockLifetime(time.Minute), // override the default lifetime option: 10s\n)\nif err := mu.Lock(); err != nil {\n    return err\n}\ndefer mu.Unlock()\n\n// do sth.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fggicci%2Fdistlock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fggicci%2Fdistlock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fggicci%2Fdistlock/lists"}