{"id":15672670,"url":"https://github.com/v5tech/distributed-lock-examples","last_synced_at":"2025-05-06T21:44:41.928Z","repository":{"id":149461716,"uuid":"263797400","full_name":"v5tech/distributed-lock-examples","owner":"v5tech","description":"史上最全的分布式锁案例合辑。我们不造轮子，只需用好轮子！","archived":false,"fork":false,"pushed_at":"2020-10-13T21:58:33.000Z","size":1030,"stargazers_count":16,"open_issues_count":2,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T03:14:03.113Z","etag":null,"topics":["distributed-lock","hazelcast","jdbclockregistry","lock","redis","redislockregistry","zookeeper","zookeeperlockregistry"],"latest_commit_sha":null,"homepage":"","language":"Java","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/v5tech.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}},"created_at":"2020-05-14T02:42:07.000Z","updated_at":"2025-02-10T13:35:12.000Z","dependencies_parsed_at":"2023-04-19T03:16:45.236Z","dependency_job_id":null,"html_url":"https://github.com/v5tech/distributed-lock-examples","commit_stats":null,"previous_names":["v5tech/distributed-lock-examples","ameizi/distributed-lock-examples"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v5tech%2Fdistributed-lock-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v5tech%2Fdistributed-lock-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v5tech%2Fdistributed-lock-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v5tech%2Fdistributed-lock-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/v5tech","download_url":"https://codeload.github.com/v5tech/distributed-lock-examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252776447,"owners_count":21802460,"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":["distributed-lock","hazelcast","jdbclockregistry","lock","redis","redislockregistry","zookeeper","zookeeperlockregistry"],"created_at":"2024-10-03T15:29:50.816Z","updated_at":"2025-05-06T21:44:41.866Z","avatar_url":"https://github.com/v5tech.png","language":"Java","readme":"# distributed-lock-examples\n\n史上最全的分布式锁合辑(我们不造轮子，只需用好轮子！)\n\n```\ndistributed-lock-examples\n├── README.md\n├── Screenshots\n│   ├── hazelcast_management_center.png\n│   ├── hazelcast_management_center_idgenerator.png\n│   └── hazelcast_management_center_map.png\n├── distributed-consul-lock-example\n│   ├── distributed-consul-lock-example.iml\n│   ├── pom.xml\n│   └── src\n│       └── main\n│           ├── java\n│           │   └── net\n│           │       └── ameizi\n│           │           └── distributed\n│           │               └── consul\n│           │                   └── example\n│           │                       └── DistributedConsulLockExampleApplication.java\n│           └── resources\n│               └── application.properties\n├── distributed-hazelcast-lock-example\n│   ├── README.md\n│   ├── distributed-hazelcast-lock-example.iml\n│   ├── docker-compose.yaml\n│   ├── hazelcast.xml\n│   ├── pom.xml\n│   └── src\n│       ├── main\n│       │   ├── java\n│       │   │   └── net\n│       │   │       └── ameizi\n│       │   │           └── distributed\n│       │   │               └── hazelcast\n│       │   │                   └── example\n│       │   │                       ├── DistributedHazelcastLockExampleApplication.java\n│       │   │                       ├── LockController.java\n│       │   │                       └── config\n│       │   │                           └── HazelcastConfiguration.java\n│       │   └── resources\n│       │       └── application.properties\n│       └── test\n│           ├── java\n│           │   └── net\n│           │       └── ameizi\n│           │           └── distributed\n│           │               └── hazelcast\n│           │                   └── example\n│           │                       ├── FlakeIdGeneratorSample.java\n│           │                       └── HazelcastClientTest.java\n│           └── resources\n├── distributed-redis-lock-example\n│   ├── distributed-redis-lock-example.iml\n│   ├── pom.xml\n│   └── src\n│       └── main\n│           ├── java\n│           │   └── net\n│           │       └── ameizi\n│           │           └── distributed\n│           │               └── lock\n│           │                   └── redis\n│           │                       └── example\n│           │                           └── DistributedRedisLockExampleApplication.java\n│           └── resources\n│               ├── application.properties\n│               ├── redisson-cluster.yaml\n│               ├── redisson-master-slave.yaml\n│               ├── redisson-sentinel.yaml\n│               └── redisson-single.yaml\n├── distributed-zookeeper-lock-example\n│   ├── distributed-zookeeper-lock-example.iml\n│   ├── pom.xml\n│   └── src\n│       ├── main\n│       │   ├── java\n│       │   │   └── net\n│       │   │       └── ameizi\n│       │   │           └── distributed\n│       │   │               └── lock\n│       │   │                   └── zookeeper\n│       │   │                       └── example\n│       │   │                           ├── DistributedZookeeperLockExampleApplication.java\n│       │   │                           └── config\n│       │   │                               ├── ZookeeperConfig.java\n│       │   │                               └── ZookeeperProperties.java\n│       │   └── resources\n│       │       ├── META-INF\n│       │       └── application.properties\n│       └── test\n│           ├── java\n│           │   └── net\n│           │       └── ameizi\n│           │           └── distributed\n│           │               └── lock\n│           │                   └── zookeeper\n│           │                       └── example\n│           │                           ├── BlockingLockTest.java\n│           │                           ├── DistributedLockTest.java\n│           │                           └── NonBlockingLockTest.java\n│           └── resources\n├── pom.xml\n└── spring-integration-distributed-lock-examples\n    ├── pom.xml\n    ├── spring-integration-distributed-lock-examples.iml\n    └── src\n        └── main\n            ├── java\n            │   └── spring\n            │       └── integration\n            │           └── distributed\n            │               └── lock\n            │                   └── examples\n            │                       ├── DistributedLockRegistryApplication.java\n            │                       └── config\n            │                           ├── JdbcConfiguration.java\n            │                           ├── RedisLockConfiguration.java\n            │                           └── ZookeeperLockConfiguration.java\n            └── resources\n                └── application.properties\n```\n\n注：为学习实验方便，示例代码中的zookeeper、redis、jdbc、hazelcast均使用本地嵌入式，实际应用应使用独立部署的服务。\n\n* distributed-hazelcast-lock-example(hazelcast实现分布式锁及分布式id)\n\n修改`docker-compose.yaml`和`hazelcast.xml`中宿主机的IP 地址后执行`docker-compose up -d`即可启动一个三个节点的hazelcast集群。\n\n浏览地址栏访问`http://localhost:8080/hazelcast-mancenter`可访问`hazelcast`的控制台\n\n三台子节点信息\n\n![](Screenshots/hazelcast_management_center.png)\n\n分布式 id\n\n![](Screenshots/hazelcast_management_center_idgenerator.png)\n\nmap\n\n![](Screenshots/hazelcast_management_center_map.png)\n\n* distributed-redis-lock-example(redis 实现分布式锁)\n\n* distributed-zookeeper-lock-example(zookeeper 实现分布式锁)\n\n* spring-integration-distributed-lock-examples(spring-integration 实现分布式锁) 分别使用ZookeeperLockRegistry、RedisLockRegistry、JdbcLockRegistry实现分布式锁\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv5tech%2Fdistributed-lock-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fv5tech%2Fdistributed-lock-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv5tech%2Fdistributed-lock-examples/lists"}