Skip to content

Commit

Permalink
Merge pull request #1 from codebaorg/bugfix-script
Browse files Browse the repository at this point in the history
Bugfix script
  • Loading branch information
codebaorg authored Dec 1, 2024
2 parents aa6ea5c + 775fa31 commit 1e99366
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 30 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>org.codeba</groupId>
<artifactId>redis-keeper</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>

<name>redis-keeper</name>
<description>Redis-keeper is a lightweight multi-data source management tool for redis.</description>
Expand All @@ -43,7 +43,7 @@
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<redis-keeper.version>2024.2.0</redis-keeper.version>
<redis-keeper.version>2024.2.1</redis-keeper.version>
<redisson.version>3.35.0</redisson.version>

<spring.version>5.3.27</spring.version>
Expand Down
2 changes: 1 addition & 1 deletion redis-keeper-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.codeba</groupId>
<artifactId>redis-keeper</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>
</parent>

<artifactId>redis-keeper-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion redis-keeper-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<groupId>org.codeba</groupId>
<artifactId>redis-keeper-example</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>

<packaging>pom</packaging>

Expand Down
4 changes: 2 additions & 2 deletions redis-keeper-example/redis-keeper-example-springboot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.codeba</groupId>
<artifactId>redis-keeper-example</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>
</parent>

<artifactId>redis-keeper-example-springboot</artifactId>
Expand Down Expand Up @@ -48,7 +48,7 @@
<dependency>
<groupId>org.codeba</groupId>
<artifactId>redis-keeper-spring-boot-starter</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<dependency>
<groupId>org.codeba</groupId>
<artifactId>redis-keeper-spring-boot-starter</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>
</dependency>

<dependency>
Expand Down
6 changes: 3 additions & 3 deletions redis-keeper-example/redis-keeper-example-standalone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.codeba</groupId>
<artifactId>redis-keeper-example</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>
</parent>

<artifactId>redis-keeper-example-standalone</artifactId>
Expand All @@ -37,13 +37,13 @@
<dependency>
<groupId>org.codeba</groupId>
<artifactId>redis-keeper-core</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>
</dependency>

<dependency>
<groupId>org.codeba</groupId>
<artifactId>redis-keeper-support</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion redis-keeper-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.codeba</groupId>
<artifactId>redis-keeper</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>
</parent>

<artifactId>redis-keeper-spring-boot-starter</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion redis-keeper-spring-boot3-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.codeba</groupId>
<artifactId>redis-keeper</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>
</parent>

<artifactId>redis-keeper-spring-boot3-starter</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion redis-keeper-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.codeba</groupId>
<artifactId>redis-keeper</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>
</parent>

<artifactId>redis-keeper-spring</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion redis-keeper-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.codeba</groupId>
<artifactId>redis-keeper</artifactId>
<version>2024.2.0</version>
<version>2024.2.1</version>
</parent>

<artifactId>redis-keeper-support</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2118,13 +2118,13 @@ public CompletableFuture<Void> setObjectEXAsync(String key, Object value, Durati

@Override
public Map<String, Object> mGet(String... keys) {
log("mGet", keys);
log("mGet", Arrays.toString(keys));
return kString.mGet(keys);
}

@Override
public CompletableFuture<Map<String, Object>> mGetAsync(String... keys) {
log("mGetAsync", keys);
log("mGetAsync", Arrays.toString(keys));
return kString.mGetAsync(keys);
}

Expand Down Expand Up @@ -2334,13 +2334,13 @@ public CompletableFuture<Object> executeScriptAsync(String script, List<Object>

@Override
public long exists(String... keys) {
log("exists", keys);
log("exists", Arrays.toString(keys));
return kGeneric.exists(keys);
}

@Override
public CompletableFuture<Long> existsAsync(String... keys) {
log("existsAsync", keys);
log("existsAsync", Arrays.toString(keys));
return kGeneric.existsAsync(keys);
}

Expand Down Expand Up @@ -2370,25 +2370,25 @@ public CompletableFuture<Boolean> expireAtAsync(String key, long timestamp) {

@Override
public long del(String... keys) {
log("del", keys);
log("del", Arrays.toString(keys));
return kGeneric.del(keys);
}

@Override
public CompletableFuture<Long> delAsync(String... keys) {
log("delAsync", keys);
log("delAsync", Arrays.toString(keys));
return kGeneric.delAsync(keys);
}

@Override
public long unlink(String... keys) {
log("unlink", keys);
log("unlink", Arrays.toString(keys));
return kGeneric.unlink(keys);
}

@Override
public CompletableFuture<Long> unlinkAsync(String... keys) {
log("unlinkAsync", keys);
log("unlinkAsync", Arrays.toString(keys));
return kGeneric.unlinkAsync(keys).toCompletableFuture();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ public CompletableFuture<Object> executeScriptAsync(String script, List<Object>
/* evalSha: 此处必须加上 StringCodec.INSTANCE */
final RScriptAsync rScript = getRScript();
String shaDigests = sha1DigestAsHex(script);
try {
return rScript.evalShaAsync(RScript.Mode.READ_WRITE, shaDigests, RScript.ReturnType.VALUE, keys, values).toCompletableFuture();
} catch (RedisException e) {
return rScript.evalAsync(RScript.Mode.READ_WRITE, script, RScript.ReturnType.VALUE, keys, values).toCompletableFuture();
}
return rScript.evalShaAsync(RScript.Mode.READ_WRITE, shaDigests, RScript.ReturnType.VALUE, keys, values)
.handle((result, error) -> {
if (error instanceof RedisException) {
return rScript.evalAsync(RScript.Mode.READ_WRITE, script, RScript.ReturnType.VALUE, keys, values)
.toCompletableFuture()
.join();
}
return result;
})
.toCompletableFuture();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public CompletableFuture<Object> getAsync(String key) {
return getRBucket(key, getCodec()).getAsync()
.handle((object, throwable) -> {
if (null != throwable) {
return getRBucket(key).getAsync().join();
return getRBucket(key).getAsync().toCompletableFuture().join();
}
return object;
}).toCompletableFuture();
Expand All @@ -78,7 +78,7 @@ public CompletableFuture<Object> getObjectAsync(String key) {
return getRBucket(key).getAsync()
.handle((object, throwable) -> {
if (null != throwable) {
return getRBucket(key, getCodec()).getAsync().join();
return getRBucket(key, getCodec()).getAsync().toCompletableFuture().join();
}
return object;
}).toCompletableFuture();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.codeba.redis.keeper.core.KStringAsync;
import org.codeba.redis.keeper.core.KZSetAsync;
import org.codeba.redis.keeper.core.KeyType;
import org.redisson.api.RedissonClient;
import org.redisson.codec.JsonJacksonCodec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -4799,7 +4800,7 @@ public void testExecuteScript() throws NoSuchAlgorithmException {
* @throws NoSuchAlgorithmException the no such algorithm exception
*/
public void testExecuteScriptAsync() throws NoSuchAlgorithmException {
String saddNxLua = "local added = {};" +
String saddNxLua = "local pp = {};local added = {};" +
"for i, v in ipairs(ARGV) do" +
" local addResult = redis.call('SADD', KEYS[1], ARGV[i]);" +
" if( addResult < 1 ) then" +
Expand Down Expand Up @@ -5090,4 +5091,20 @@ public void testTryAcquire2Async() {
CACHE_TEMPLATE.del(key, "{" + key + "}:permits", "{" + key + "}:value");
}

public void testDefaultRedissonTemplate() {
String key = "my-key-adapter";
Object value = KeyType.LIST;

DefaultRedissonTemplate defaultRedissonTemplate = (DefaultRedissonTemplate) CACHE_TEMPLATE;
final RedissonClient redissonClient = defaultRedissonTemplate.getRedissonClient();
final boolean add = redissonClient.getScoredSortedSet(key).add(1, value);
assertTrue(add);

final boolean zRem = CACHE_TEMPLATE.zRem(key, Collections.singletonList(value));
assertFalse(zRem);

CACHE_TEMPLATE.del(key);

}

}

0 comments on commit 1e99366

Please sign in to comment.