From 8efc7db9c718c43119517a474e6b422e29a72f32 Mon Sep 17 00:00:00 2001 From: "binbin.hou" Date: Thu, 10 Sep 2020 14:03:35 +0800 Subject: [PATCH] release branch 0.0.1 --- README.md | 43 ++++++++++++++++++- lock-api/pom.xml | 2 +- lock-core/pom.xml | 6 +-- lock-test/pom.xml | 26 +++++++++++ .../com/github/houbb/lock/test/JedisTest.java | 22 ++++++++++ .../github/houbb/lock/test/RedisLockTest.java | 35 +++++++++++++++ .../github/houbb/lock/test/package-info.java | 1 + pom.xml | 5 ++- release.bat | 4 +- 9 files changed, 134 insertions(+), 10 deletions(-) create mode 100644 lock-test/pom.xml create mode 100644 lock-test/src/test/java/com/github/houbb/lock/test/JedisTest.java create mode 100644 lock-test/src/test/java/com/github/houbb/lock/test/RedisLockTest.java create mode 100644 lock-test/src/test/java/com/github/houbb/lock/test/package-info.java diff --git a/README.md b/README.md index 346359f..650be76 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,46 @@ maven 3.x+ ```xml com.github.houbb - lock + lock-core ${最新版本} -``` \ No newline at end of file +``` + +## 入门例子 + +基于本地 redis 的测试案例。 + +```java +Jedis jedis = new Jedis("127.0.0.1", 6379); +IOperator operator = new JedisOperator(jedis); + +// 获取锁 +ILock lock = LockRedisBs.newInstance().operator(operator).lock(); + +try { + boolean lockResult = lock.tryLock(); + System.out.println(lockResult); + // 业务处理 +} catch (Exception e) { + e.printStackTrace(); +} finally { + lock.unlock(); +} +``` + +# 后期 Road-MAP + +- [ ] 支持锁的可重入 + +持有锁的线程可以多次获取锁 + +- [ ] redis 实现的支持 + +cluster 支持 + +redis 支持 + +aliyun-redis 支持 + +各种各样的声明方式的默认支持 + diff --git a/lock-api/pom.xml b/lock-api/pom.xml index 72f8a4e..b456eea 100644 --- a/lock-api/pom.xml +++ b/lock-api/pom.xml @@ -5,7 +5,7 @@ lock com.github.houbb - 0.0.1-SNAPSHOT + 0.0.1 4.0.0 diff --git a/lock-core/pom.xml b/lock-core/pom.xml index 5840a21..82acbc9 100644 --- a/lock-core/pom.xml +++ b/lock-core/pom.xml @@ -5,12 +5,12 @@ lock com.github.houbb - 0.0.1-SNAPSHOT + 0.0.1 4.0.0 - lock-redis - The lock depends on redis. + lock-core + The core lock implements. diff --git a/lock-test/pom.xml b/lock-test/pom.xml new file mode 100644 index 0000000..0c21e5a --- /dev/null +++ b/lock-test/pom.xml @@ -0,0 +1,26 @@ + + + + lock + com.github.houbb + 0.0.1 + + 4.0.0 + + lock-test + + + + com.github.houbb + lock-core + + + + junit + junit + + + + \ No newline at end of file diff --git a/lock-test/src/test/java/com/github/houbb/lock/test/JedisTest.java b/lock-test/src/test/java/com/github/houbb/lock/test/JedisTest.java new file mode 100644 index 0000000..c8a2aad --- /dev/null +++ b/lock-test/src/test/java/com/github/houbb/lock/test/JedisTest.java @@ -0,0 +1,22 @@ +package com.github.houbb.lock.test; + +import org.junit.Assert; +import org.junit.Test; +import redis.clients.jedis.Jedis; + +/** + * @author binbin.hou + * @since 0.0.1 + */ +public class JedisTest { + + @Test + public void helloTest() { + Jedis jedis = new Jedis("127.0.0.1", 6379); + jedis.set("key", "001"); + String value = jedis.get("key"); + + Assert.assertEquals("001", value); + } + +} diff --git a/lock-test/src/test/java/com/github/houbb/lock/test/RedisLockTest.java b/lock-test/src/test/java/com/github/houbb/lock/test/RedisLockTest.java new file mode 100644 index 0000000..5509ccd --- /dev/null +++ b/lock-test/src/test/java/com/github/houbb/lock/test/RedisLockTest.java @@ -0,0 +1,35 @@ +package com.github.houbb.lock.test; + +import com.github.houbb.lock.api.core.ILock; +import com.github.houbb.lock.redis.bs.LockRedisBs; +import com.github.houbb.lock.redis.support.operator.IOperator; +import com.github.houbb.lock.redis.support.operator.impl.JedisOperator; +import org.junit.Test; +import redis.clients.jedis.Jedis; + +/** + * @author binbin.hou + * @since 0.0.1 + */ +public class RedisLockTest { + + @Test + public void helloTest() { + Jedis jedis = new Jedis("127.0.0.1", 6379); + IOperator operator = new JedisOperator(jedis); + + // 获取锁 + ILock lock = LockRedisBs.newInstance().operator(operator).lock(); + + try { + boolean lockResult = lock.tryLock(); + System.out.println(lockResult); + // 业务处理 + } catch (Exception e) { + e.printStackTrace(); + } finally { + lock.unlock(); + } + } + +} diff --git a/lock-test/src/test/java/com/github/houbb/lock/test/package-info.java b/lock-test/src/test/java/com/github/houbb/lock/test/package-info.java new file mode 100644 index 0000000..bf02430 --- /dev/null +++ b/lock-test/src/test/java/com/github/houbb/lock/test/package-info.java @@ -0,0 +1 @@ +package com.github.houbb.lock.test; \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9822b50..5dd3c95 100644 --- a/pom.xml +++ b/pom.xml @@ -5,10 +5,11 @@ com.github.houbb lock pom - 0.0.1-SNAPSHOT + 0.0.1 lock-api lock-core + lock-test @@ -51,7 +52,7 @@ com.github.houbb - lock-redis + lock-core ${project.version} diff --git a/release.bat b/release.bat index e57730e..b2d7667 100644 --- a/release.bat +++ b/release.bat @@ -10,9 +10,9 @@ ECHO "============================= RELEASE START..." :: 版本号信息(需要手动指定) :::: 旧版本名称 -SET version=0.1.112 +SET version=0.0.1 :::: 新版本名称 -SET newVersion=0.1.113 +SET newVersion=0.0.2 :::: 组织名称 SET groupName=com.github.houbb :::: 项目名称