Compare commits
4 Commits
release_1.
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ef657d0ba | ||
|
|
0f9ce0441e | ||
|
|
bc1fd8fc71 | ||
|
|
4ce823e161 |
@@ -53,3 +53,9 @@
|
|||||||
| 1 | A | 添加 keyFormat | 2022-12-8 14:45:40 | |
|
| 1 | A | 添加 keyFormat | 2022-12-8 14:45:40 | |
|
||||||
| 2 | A | 添加锁释放失败 | 2022-12-8 14:45:40 | |
|
| 2 | A | 添加锁释放失败 | 2022-12-8 14:45:40 | |
|
||||||
| 3 | O | 加锁处理优化,接口统一优化 | 2022-12-8 14:45:40 | |
|
| 3 | O | 加锁处理优化,接口统一优化 | 2022-12-8 14:45:40 | |
|
||||||
|
|
||||||
|
# release_1.3.0
|
||||||
|
|
||||||
|
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|
||||||
|
|:---|:---|:---|:---|:--|
|
||||||
|
| 1 | A | 让 redis-config 主动启用,避免无法主动管理的情况 | 2022-12-8 14:45:40 | |
|
||||||
|
|||||||
48
README.md
48
README.md
@@ -1,23 +1,27 @@
|
|||||||
# 项目简介
|
# 项目简介
|
||||||
|
|
||||||
[lock](https://github.com/houbb/lock) 为 java 设计的分布式锁。
|
[lock](https://github.com/houbb/lock) 为 java 设计的分布式锁,开箱即用,纵享丝滑。
|
||||||
|
|
||||||
[](http://mvnrepository.com/artifact/com.github.houbb/lock)
|
[](http://mvnrepository.com/artifact/com.github.houbb/lock)
|
||||||
[](https://www.travis-ci.org/houbb/lock?branch=master)
|
[](https://www.travis-ci.org/houbb/lock?branch=master)
|
||||||
[](https://coveralls.io/github/houbb/lock?branch=master)
|
[](https://coveralls.io/github/houbb/lock?branch=master)
|
||||||
|
|
||||||
|
开源地址:[https://github.com/houbb/lock](https://github.com/houbb/lock)
|
||||||
|
|
||||||
## 目的
|
## 目的
|
||||||
|
|
||||||
- 开箱即用,支持注解式和过程式调用
|
- 开箱即用,支持注解式和过程式调用
|
||||||
|
|
||||||
- 基于 redis 的分布式锁
|
- 基于 redis 的分布式锁
|
||||||
|
|
||||||
|
- 内置支持多种 redis 的整合方式
|
||||||
|
|
||||||
|
- 渐进式设计,可独立于 spring 使用
|
||||||
|
|
||||||
- 整合 spring
|
- 整合 spring
|
||||||
|
|
||||||
- 整合 spring-boot
|
- 整合 spring-boot
|
||||||
|
|
||||||
- 支持多种 redis 的整合方式
|
|
||||||
|
|
||||||
# 变更日志
|
# 变更日志
|
||||||
|
|
||||||
> [变更日志](CHANGELOG.md)
|
> [变更日志](CHANGELOG.md)
|
||||||
@@ -36,7 +40,7 @@ maven 3.x+
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.houbb</groupId>
|
<groupId>com.github.houbb</groupId>
|
||||||
<artifactId>lock-core</artifactId>
|
<artifactId>lock-core</artifactId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -83,7 +87,7 @@ LockBs.newInstance()
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.houbb</groupId>
|
<groupId>com.github.houbb</groupId>
|
||||||
<artifactId>lock-spring</artifactId>
|
<artifactId>lock-spring</artifactId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -93,10 +97,13 @@ LockBs.newInstance()
|
|||||||
|
|
||||||
`@EnableLock` 启用分布式锁。
|
`@EnableLock` 启用分布式锁。
|
||||||
|
|
||||||
|
`@EnableRedisConfig` 启用 redis 的默认配置。
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
@Configurable
|
@Configurable
|
||||||
@ComponentScan(basePackages = "com.github.houbb.lock.test.service")
|
@ComponentScan(basePackages = "com.github.houbb.lock.test.service")
|
||||||
@EnableLock
|
@EnableLock
|
||||||
|
@EnableRedisConfig
|
||||||
public class SpringConfig {
|
public class SpringConfig {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -109,7 +116,6 @@ public @interface EnableLock {
|
|||||||
/**
|
/**
|
||||||
* 唯一标识生成策略
|
* 唯一标识生成策略
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* @since 1.1.0
|
|
||||||
*/
|
*/
|
||||||
String id() default "lockId";
|
String id() default "lockId";
|
||||||
|
|
||||||
@@ -119,21 +125,18 @@ public @interface EnableLock {
|
|||||||
* 默认引入 redis-config 中的配置
|
* 默认引入 redis-config 中的配置
|
||||||
*
|
*
|
||||||
* @return 实现
|
* @return 实现
|
||||||
* @since 1.1.0
|
|
||||||
*/
|
*/
|
||||||
String cache() default "springRedisService";
|
String cache() default "springRedisService";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加锁 key 格式化策略
|
* 加锁 key 格式化策略
|
||||||
* @return 策略
|
* @return 策略
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
*/
|
||||||
String lockKeyFormat() default "lockKeyFormat";
|
String lockKeyFormat() default "lockKeyFormat";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 锁释放失败处理类
|
* 锁释放失败处理类
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
*/
|
||||||
String lockReleaseFailHandler() default "lockReleaseFailHandler";
|
String lockReleaseFailHandler() default "lockReleaseFailHandler";
|
||||||
|
|
||||||
@@ -142,7 +145,7 @@ public @interface EnableLock {
|
|||||||
|
|
||||||
其中 `springRedisService` 使用的是 [redis-config](https://github.com/houbb/redis-config) 中的实现。
|
其中 `springRedisService` 使用的是 [redis-config](https://github.com/houbb/redis-config) 中的实现。
|
||||||
|
|
||||||
redis 的配置信息如下:
|
对应注解 `@EnableRedisConfig`,redis 的配置信息如下:
|
||||||
|
|
||||||
| 配置 | 说明 | 默认值
|
| 配置 | 说明 | 默认值
|
||||||
|:---|:---|:----|
|
|:---|:---|:----|
|
||||||
@@ -219,21 +222,18 @@ public @interface Lock {
|
|||||||
/**
|
/**
|
||||||
* 时间单位
|
* 时间单位
|
||||||
* @return 单位
|
* @return 单位
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
*/
|
||||||
TimeUnit timeUnit() default TimeUnit.SECONDS;
|
TimeUnit timeUnit() default TimeUnit.SECONDS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 等待锁时间
|
* 等待锁时间
|
||||||
* @return 等待锁时间
|
* @return 等待锁时间
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
*/
|
||||||
long waitLockTime() default 10;
|
long waitLockTime() default 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务加锁时间
|
* 业务加锁时间
|
||||||
* @return 加锁时间
|
* @return 加锁时间
|
||||||
* @since 1.2.0
|
|
||||||
*/
|
*/
|
||||||
long lockTime() default 60;
|
long lockTime() default 60;
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ public @interface Lock {
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.houbb</groupId>
|
<groupId>com.github.houbb</groupId>
|
||||||
<artifactId>lock-springboot-starter</artifactId>
|
<artifactId>lock-springboot-starter</artifactId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -263,3 +263,23 @@ public @interface Lock {
|
|||||||
持有锁的线程可以多次获取锁
|
持有锁的线程可以多次获取锁
|
||||||
|
|
||||||
- [x] 分布式锁注解支持
|
- [x] 分布式锁注解支持
|
||||||
|
|
||||||
|
# 拓展阅读
|
||||||
|
|
||||||
|
[Redis 分布式锁](https://houbb.github.io/2018/09/08/redis-learn-42-distributed-lock-redis)
|
||||||
|
|
||||||
|
[java 从零实现 redis 分布式锁](https://houbb.github.io/2018/09/08/redis-learn-43-distributed-lock-redis-java-impl)
|
||||||
|
|
||||||
|
# 缓存相关工具
|
||||||
|
|
||||||
|
[cache: 手写渐进式 redis](https://github.com/houbb/cache)
|
||||||
|
|
||||||
|
[common-cache: 通用缓存标准定义](https://github.com/houbb/common-cache)
|
||||||
|
|
||||||
|
[redis-config: 兼容各种常见的 redis 配置模式](https://github.com/houbb/redis-config)
|
||||||
|
|
||||||
|
[lock: 开箱即用的分布式锁](https://github.com/houbb/lock)
|
||||||
|
|
||||||
|
[resubmit: 防重复提交](https://github.com/houbb/resubmit)
|
||||||
|
|
||||||
|
[rate-limit: 限流](https://github.com/houbb/rate-limit/)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>lock</artifactId>
|
<artifactId>lock</artifactId>
|
||||||
<groupId>com.github.houbb</groupId>
|
<groupId>com.github.houbb</groupId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>lock</artifactId>
|
<artifactId>lock</artifactId>
|
||||||
<groupId>com.github.houbb</groupId>
|
<groupId>com.github.houbb</groupId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>lock</artifactId>
|
<artifactId>lock</artifactId>
|
||||||
<groupId>com.github.houbb</groupId>
|
<groupId>com.github.houbb</groupId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.github.houbb.lock.spring.config;
|
|
||||||
|
|
||||||
import com.github.houbb.redis.config.spring.annotation.EnableRedisConfig;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* bean 配置
|
|
||||||
*
|
|
||||||
* @author binbin.hou
|
|
||||||
* @since 0.0.2
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@EnableRedisConfig
|
|
||||||
public class CommonCacheConfig {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,12 @@
|
|||||||
package com.github.houbb.lock.spring.config;
|
package com.github.houbb.lock.spring.config;
|
||||||
|
|
||||||
import com.github.houbb.common.cache.api.service.ICommonCacheService;
|
import com.github.houbb.common.cache.api.service.ICommonCacheService;
|
||||||
import com.github.houbb.heaven.util.lang.StringUtil;
|
|
||||||
import com.github.houbb.id.api.Id;
|
import com.github.houbb.id.api.Id;
|
||||||
import com.github.houbb.id.core.core.Ids;
|
|
||||||
import com.github.houbb.lock.api.core.ILockKeyFormat;
|
import com.github.houbb.lock.api.core.ILockKeyFormat;
|
||||||
import com.github.houbb.lock.api.core.ILockReleaseFailHandler;
|
import com.github.houbb.lock.api.core.ILockReleaseFailHandler;
|
||||||
import com.github.houbb.lock.core.bs.LockBs;
|
import com.github.houbb.lock.core.bs.LockBs;
|
||||||
import com.github.houbb.lock.spring.annotation.EnableLock;
|
import com.github.houbb.lock.spring.annotation.EnableLock;
|
||||||
import com.github.houbb.redis.config.core.factory.JedisRedisServiceFactory;
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.context.annotation.*;
|
import org.springframework.context.annotation.*;
|
||||||
@@ -25,7 +21,7 @@ import org.springframework.core.type.AnnotationMetadata;
|
|||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages = "com.github.houbb.lock.spring")
|
@ComponentScan(basePackages = "com.github.houbb.lock.spring")
|
||||||
@Import({LockBeanConfig.class, CommonCacheConfig.class})
|
@Import({LockBeanConfig.class})
|
||||||
public class LockAopConfig implements ImportAware, BeanFactoryPostProcessor {
|
public class LockAopConfig implements ImportAware, BeanFactoryPostProcessor {
|
||||||
|
|
||||||
@Bean("lockBs")
|
@Bean("lockBs")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>lock</artifactId>
|
<artifactId>lock</artifactId>
|
||||||
<groupId>com.github.houbb</groupId>
|
<groupId>com.github.houbb</groupId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -17,9 +17,15 @@
|
|||||||
<artifactId>lock-spring</artifactId>
|
<artifactId>lock-spring</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.houbb</groupId>
|
||||||
|
<artifactId>redis-config-springboot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.github.houbb.lock.springboot.starter.config;
|
package com.github.houbb.lock.springboot.starter.config;
|
||||||
|
|
||||||
import com.github.houbb.lock.spring.annotation.EnableLock;
|
import com.github.houbb.lock.spring.annotation.EnableLock;
|
||||||
import com.github.houbb.lock.spring.config.LockAopConfig;
|
|
||||||
import com.github.houbb.redis.config.spring.annotation.EnableRedisConfig;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>lock</artifactId>
|
<artifactId>lock</artifactId>
|
||||||
<groupId>com.github.houbb</groupId>
|
<groupId>com.github.houbb</groupId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.github.houbb.lock.test.config;
|
|||||||
|
|
||||||
|
|
||||||
import com.github.houbb.lock.spring.annotation.EnableLock;
|
import com.github.houbb.lock.spring.annotation.EnableLock;
|
||||||
|
import com.github.houbb.redis.config.spring.annotation.EnableRedisConfig;
|
||||||
import org.springframework.beans.factory.annotation.Configurable;
|
import org.springframework.beans.factory.annotation.Configurable;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
@@ -12,5 +13,6 @@ import org.springframework.context.annotation.ComponentScan;
|
|||||||
@Configurable
|
@Configurable
|
||||||
@ComponentScan(basePackages = "com.github.houbb.lock.test.service")
|
@ComponentScan(basePackages = "com.github.houbb.lock.test.service")
|
||||||
@EnableLock
|
@EnableLock
|
||||||
|
@EnableRedisConfig
|
||||||
public class SpringConfig {
|
public class SpringConfig {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>lock</artifactId>
|
<artifactId>lock</artifactId>
|
||||||
<groupId>com.github.houbb</groupId>
|
<groupId>com.github.houbb</groupId>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
7
pom.xml
7
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
<groupId>com.github.houbb</groupId>
|
<groupId>com.github.houbb</groupId>
|
||||||
<artifactId>lock</artifactId>
|
<artifactId>lock</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.2.0</version>
|
<version>1.3.0</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>lock-api</module>
|
<module>lock-api</module>
|
||||||
<module>lock-core</module>
|
<module>lock-core</module>
|
||||||
@@ -123,6 +123,11 @@
|
|||||||
<artifactId>redis-config-spring</artifactId>
|
<artifactId>redis-config-spring</artifactId>
|
||||||
<version>${redis-config.version}</version>
|
<version>${redis-config.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.houbb</groupId>
|
||||||
|
<artifactId>redis-config-springboot-starter</artifactId>
|
||||||
|
<version>${redis-config.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--============================== OTHER ==============================-->
|
<!--============================== OTHER ==============================-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ ECHO "============================= RELEASE START..."
|
|||||||
|
|
||||||
:: 版本号信息(需要手动指定)
|
:: 版本号信息(需要手动指定)
|
||||||
:::: 旧版本名称
|
:::: 旧版本名称
|
||||||
SET version=1.2.0
|
SET version=1.3.0
|
||||||
:::: 新版本名称
|
:::: 新版本名称
|
||||||
SET newVersion=1.3.0
|
SET newVersion=1.4.0
|
||||||
:::: 组织名称
|
:::: 组织名称
|
||||||
SET groupName=com.github.houbb
|
SET groupName=com.github.houbb
|
||||||
:::: 项目名称
|
:::: 项目名称
|
||||||
|
|||||||
Reference in New Issue
Block a user