Skip to content

Commit

Permalink
upd 0.0.3
Browse files Browse the repository at this point in the history
Change-Id: Ia7142f4eb705cfdd1c2d6ce7b1eeffc64fa0b7fb
  • Loading branch information
boylong12 committed Mar 24, 2022
1 parent b02b8ec commit cbc22b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dlock-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>com.github.boylong12</groupId>
<artifactId>dlock-spring-boot-starter</artifactId>
<version>0.0.2</version>
<version>0.0.3</version>
<packaging>jar</packaging>
<name>dlock-spring-boot-starter</name>

Expand All @@ -25,7 +25,7 @@
<connection>scm:git@github.com:boylong12/dlock.git</connection>
<developerConnection>scm:git@github.com:boylong12/dlock.git</developerConnection>
<url>git@github.com:boylong12/dlock.git</url>
<tag>v0.0.2.release</tag>
<tag>v0.0.3.release</tag>
</scm>
<developers>
<developer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public boolean tryLock(String key, String value, long expireTime) {

/**
* 解锁:
* 匹配随机数,删除redis上的特定的key数据,
* 要保证获取数据,判断一致以及删除数据三个操作是原子性
* 1 需要验证value是和加锁的一致才删除key。
* 这是避免了一种情况:假设A获取了锁,过期时间30s,此时35s之后,锁已经自动释放了,A去释放锁,但是此时可能B获取了锁。A客户端就不能删除B的锁了。
* 2 删除redis上的特定的key数据,要保证获取数据,判断一致以及删除数据三个操作是原子性
* 执行如下lua脚本:
* if redis.call('get', KEYS[1]) == ARGV[1] then
* return redis.call('del', KEYS[1])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ private String getSpelDefinitionKey(String[] definitionKeys, Method method, Obje
List<String> definitionKeyList = new ArrayList<>(definitionKeys.length);
for (String definitionKey : definitionKeys) {
if (definitionKey != null && !definitionKey.isEmpty()) {
String key = PARSER.parseExpression(definitionKey).getValue(context).toString();
definitionKeyList.add(key);
Object obj = PARSER.parseExpression(definitionKey).getValue(context);
if (obj != null) {
String key = obj.toString();
definitionKeyList.add(key);
}
}
}
return StringUtils.collectionToDelimitedString(definitionKeyList, "-", "", "");
Expand Down

0 comments on commit cbc22b3

Please sign in to comment.