release branch 0.0.1

This commit is contained in:
binbin.hou
2020-09-10 14:03:35 +08:00
parent 3a8c68a19d
commit 8efc7db9c7
9 changed files with 134 additions and 10 deletions

26
lock-test/pom.xml Normal file
View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>lock</artifactId>
<groupId>com.github.houbb</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lock-test</artifactId>
<dependencies>
<dependency>
<groupId>com.github.houbb</groupId>
<artifactId>lock-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -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);
}
}

View File

@@ -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();
}
}
}

View File

@@ -0,0 +1 @@
package com.github.houbb.lock.test;