release branch 0.0.1
This commit is contained in:
26
lock-test/pom.xml
Normal file
26
lock-test/pom.xml
Normal 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>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package com.github.houbb.lock.test;
|
||||
Reference in New Issue
Block a user