Fixed - JCache hangs forever when getting value from cache with useScriptCache=true

pull/4308/head
Nikita Koksharov
parent c916aa76df
commit 8e7d73dc3c

@ -75,6 +75,10 @@ public interface CommandAsyncExecutor {
<R> List<CompletableFuture<R>> executeMasters(RedisCommand<?> command, Object... params);
<R> List<CompletableFuture<R>> executeRead(Codec codec, RedisCommand<?> command, Object... params);
<R> List<CompletableFuture<R>> executeRead(RedisCommand<?> command, Object... params);
<T, R> RFuture<Collection<R>> readAllAsync(Codec codec, RedisCommand<T> command, Object... params);
<R, T> RFuture<R> readAllAsync(RedisCommand<T> command, SlotCallback<T, R> callback, Object... params);

@ -265,6 +265,20 @@ public class CommandAsyncService implements CommandAsyncExecutor {
return futures;
}
@Override
public <R> List<CompletableFuture<R>> executeRead(Codec codec, RedisCommand<?> command, Object... params) {
List<CompletableFuture<R>> futures = connectionManager.getEntrySet().stream().map(e -> {
RFuture<R> f = async(true, new NodeSource(e), codec, command, params, true, false);
return f.toCompletableFuture();
}).collect(Collectors.toList());
return futures;
}
@Override
public <R> List<CompletableFuture<R>> executeRead(RedisCommand<?> command, Object... params) {
return executeRead(connectionManager.getCodec(), command, params);
}
@Override
public <R> List<CompletableFuture<R>> executeAll(RedisCommand<?> command, Object... params) {
Collection<MasterSlaveEntry> nodes = connectionManager.getEntrySet();
@ -492,8 +506,7 @@ public class CommandAsyncService implements CommandAsyncExecutor {
if (e != null) {
if (e.getMessage().startsWith("ERR unknown command")) {
evalShaROSupported.set(false);
free(pps);
RFuture<R> future = evalAsync(nodeSource, readOnlyMode, codec, evalCommandType, script, keys, noRetry, params);
RFuture<R> future = evalAsync(nodeSource, readOnlyMode, codec, evalCommandType, script, keys, noRetry, pps);
transfer(future.toCompletableFuture(), mainPromise);
} else if (e.getMessage().startsWith("NOSCRIPT")) {
RFuture<String> loadFuture = loadScript(executor.getRedisClient(), script);

@ -352,7 +352,30 @@ public class JCacheTest extends BaseTest {
cache.close();
runner.stop();
}
@Test
public void testScriptCache() throws IOException, InterruptedException {
RedisProcess runner = new RedisRunner()
.nosave()
.randomDir()
.port(6311)
.run();
URL configUrl = getClass().getResource("redisson-jcache.yaml");
Config cfg = Config.fromYAML(configUrl);
cfg.setUseScriptCache(true);
Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg);
Cache<String, String> cache = Caching.getCachingProvider().getCacheManager()
.createCache("test", config);
cache.put("1", "2");
Assertions.assertEquals("2", cache.get("1"));
cache.close();
runner.stop();
}
@Test
public void testRedissonInstance() throws IllegalArgumentException {
Configuration<String, String> config = RedissonConfiguration.fromInstance(redisson);

Loading…
Cancel
Save