{"id":37424786,"url":"https://github.com/imadcn/redislock","last_synced_at":"2026-01-16T06:11:53.252Z","repository":{"id":57725170,"uuid":"107643409","full_name":"imadcn/redislock","owner":"imadcn","description":"基于Redis的分布式可重入锁","archived":false,"fork":false,"pushed_at":"2018-10-17T05:52:27.000Z","size":27,"stargazers_count":3,"open_issues_count":0,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-28T02:24:27.795Z","etag":null,"topics":["distributed","java","lock","redis","reentrant"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/imadcn.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}},"created_at":"2017-10-20T07:01:13.000Z","updated_at":"2019-07-28T10:11:35.000Z","dependencies_parsed_at":"2022-09-11T20:21:17.752Z","dependency_job_id":null,"html_url":"https://github.com/imadcn/redislock","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/imadcn/redislock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imadcn%2Fredislock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imadcn%2Fredislock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imadcn%2Fredislock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imadcn%2Fredislock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imadcn","download_url":"https://codeload.github.com/imadcn/redislock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imadcn%2Fredislock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T03:13:13.607Z","status":"ssl_error","status_checked_at":"2026-01-16T03:11:47.863Z","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","java","lock","redis","reentrant"],"created_at":"2026-01-16T06:11:52.658Z","updated_at":"2026-01-16T06:11:53.245Z","avatar_url":"https://github.com/imadcn.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## redislock - 基于redis的分布式可重入锁\n\n[![Build Status](https://travis-ci.org/imadcn/redislock.svg?branch=master)](https://travis-ci.org/imadcn/redislock)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.imadcn.framework/lock/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.imadcn.framework/lock)\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n\n### 是什么\nredislock 是一个基于Redis的分布式可重入锁\n\n### 怎么用\n#### maven\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.imadcn.framework\u003c/groupId\u003e\n  \u003cartifactId\u003elock\u003c/artifactId\u003e\n  \u003cversion\u003e0.0.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n#### XML配置 \n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cbeans xmlns=\"http://www.springframework.org/schema/beans\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:context=\"http://www.springframework.org/schema/context\" xmlns:p=\"http://www.springframework.org/schema/p\" xmlns:lock=\"http://code.imadcn.com/schema/lock\"\n\txsi:schemaLocation=\"\n\t\thttp://www.springframework.org/schema/beans \n\t\thttp://www.springframework.org/schema/beans/spring-beans.xsd\n\t\thttp://www.springframework.org/schema/context \n\t\thttp://www.springframework.org/schema/context/spring-context.xsd\n\t\thttp://code.imadcn.com/schema/lock\n\t\thttp://code.imadcn.com/schema/lock/lock.xsd\"\u003e\n\t\t\n\t\u003c!-- redis pool --\u003e\n\t\u003cbean id=\"jedisPoolConfig\" class=\"redis.clients.jedis.JedisPoolConfig\"\u003e\n\t\t\u003cproperty name=\"testOnBorrow\" value=\"false\" /\u003e\n\t\t\u003cproperty name=\"testOnReturn\" value=\"true\" /\u003e\n\t\u003c/bean\u003e\n\n\t\u003c!-- redis sentinel --\u003e\n\t\u003cbean id=\"redisSentinelConfig\" class=\"com.imadcn.framework.lock.config.RedisSentinelConfig\"\u003e\n\t\t\u003cproperty name=\"masterName\" value=\"mymaster\" /\u003e\n\t\t\u003cproperty name=\"sentinelAddrs\" value=\"127.0.0.1:26380,127.0.0.1:26381,127.0.0.1:26382\" /\u003e\n\t\u003c/bean\u003e\n\n\t\u003c!-- redis connectionFactory --\u003e\n\t\u003cbean id=\"connectionFactory\" class=\"org.springframework.data.redis.connection.jedis.JedisConnectionFactory\" destroy-method=\"destroy\"\u003e\n\t\t\u003cconstructor-arg index=\"0\" ref=\"redisSentinelConfig\" /\u003e\n\t\t\u003cconstructor-arg index=\"1\" ref=\"jedisPoolConfig\" /\u003e\n\t\u003c/bean\u003e\n\n\t\u003cbean id=\"stringRedisSerializer\" class=\"org.springframework.data.redis.serializer.StringRedisSerializer\" /\u003e\n\t\u003cbean id=\"jdkSerializationRedisSerializer\" class=\"org.springframework.data.redis.serializer.JdkSerializationRedisSerializer\" /\u003e\n\n\t\u003c!-- redisTemplate --\u003e\n\t\u003cbean id=\"redisTemplate\" class=\"org.springframework.data.redis.core.RedisTemplate\"\u003e\n\t\t\u003cproperty name=\"connectionFactory\" ref=\"connectionFactory\" /\u003e\n\t\t\u003cproperty name=\"keySerializer\" ref=\"stringRedisSerializer\" /\u003e\n\t\t\u003cproperty name=\"valueSerializer\" ref=\"stringRedisSerializer\" /\u003e\n\t\t\u003cproperty name=\"hashKeySerializer\" ref=\"stringRedisSerializer\" /\u003e\n\t\t\u003cproperty name=\"hashValueSerializer\" ref=\"stringRedisSerializer\" /\u003e\n\t\t\u003cproperty name=\"stringSerializer\" ref=\"stringRedisSerializer\" /\u003e\n\t\u003c/bean\u003e\n\t\n\t\u003c!-- redisMessageListenerContainer --\u003e\n\t\u003cbean id=\"redisMessageListenerContainer\" class=\"org.springframework.data.redis.listener.RedisMessageListenerContainer\"\u003e\n\t\t\u003cproperty name=\"connectionFactory\" ref=\"connectionFactory\" /\u003e\n\t\t\u003cproperty name=\"topicSerializer\" ref=\"stringRedisSerializer\" /\u003e\n\t\u003c/bean\u003e\n\t\n\t\u003clock:config id=\"lockManager\" group=\"physical-exam\" redisTemplate=\"redisTemplate\" messageContainer=\"redisMessageListenerContainer\"/\u003e\n\u003c/beans\u003e\n\n```\n\n#### API\n\n```java\n@Autowired\nprivate RedisLockManager manager;\n\npublic void lock() {\n\tRedisLock redisLock = manager.getLock(\"asd\");\n\tredisLock.lock();\n\tredisLock.unlock();\n} \n\n```\n\n### 配置参考\n#### \u003credislock:config /\u003e redislock 配置\n\n|属性|类型|必填|缺省值|描述|\n|:------|:------|:------|:------|:------|\n|id|String|是| |Spring容器中的ID|\n|group|String|是| |分组名，可以为不同业务分配分组|\n|redisTemplate|String|是| |redisTemplate|\n|messageContainer|String|是| |RedisMessageListenerContainer|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimadcn%2Fredislock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimadcn%2Fredislock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimadcn%2Fredislock/lists"}