Fixed - RFunction.loadAndReplace() method uses incorrect command parameters

pull/4799/head
Nikita Koksharov 2 years ago
parent 80e298c909
commit b6cb9e17a2

@ -126,8 +126,8 @@ public class RedissonFuction implements RFunction {
@Override
public RFuture<Void> loadAndReplaceAsync(String libraryName, String code) {
return commandExecutor.writeAllVoidAsync(RedisCommands.FUNCTION_LOAD,
"Lua", libraryName, "REPLACE", code);
return commandExecutor.writeAllVoidAsync(RedisCommands.FUNCTION_LOAD, "REPLACE",
"#!lua name=" + libraryName + " \n " + code);
}
@Override

@ -66,6 +66,15 @@ public class RedissonFunctionTest extends BaseTest {
RFunction f3 = redisson.getFunction(LongCodec.INSTANCE);
Long s3 = f3.call(FunctionMode.READ, "myfun3", FunctionResult.LONG, Collections.emptyList());
assertThat(s3).isEqualTo(123L);
f.loadAndReplace("lib", "redis.register_function('myfun', function(keys, args) return args[1] end)" +
"redis.register_function('myfun2', function(keys, args) return 'test2' end)" +
"redis.register_function('myfun3', function(keys, args) return 123 end)");
RFunction f4 = redisson.getFunction(StringCodec.INSTANCE);
String s4 = f4.call(FunctionMode.READ, "myfun2", FunctionResult.STRING, Collections.emptyList());
assertThat(s4).isEqualTo("test2");
}
@Test

Loading…
Cancel
Save