Trying to send RedisTimeSeries commands thru Lettuce (Java) to Redis. It worked for simple commands such as TS.Create but I couldn't get slightly more complicated commands to work (such TS.ADD which takes key, score, value as args) or TS.Range (which takes args and returns List) to work.
Redis is running on Linux (Ubuntu running on Windows 10 thru WSL), RedisTimeSeries is installed onto Redis. Redis and RedisTimeSeries commands have been tested using Redis-cli on linux, they work fine. I use VS Code + JDK 13.0 + Maven to build and test a Java client for Redis. So far Redis commands supported by Lettuce are working thru the client, plus some simple RedisTimeSeries commands.
Code snippet:
RedisCommands<String, String> syncCommands = MyRedisClient.getSyncCommands(connection);
// this works:
RedisCodec<String, String> codec = StringCodec.UTF8;
String result = syncCommands.dispatch(TS.CREATE, new StatusOutput<>(codec),new CommandArgs<>(codec).addKey("myTS"));
System.out.println("Custom Command TS.CREATE " + result);
//custom command definition:
public enum TS implements ProtocolKeyword{
CREATE;
public final byte[] bytes;
private TS() {
bytes = "TS.CREATE".getBytes(StandardCharsets.US_ASCII);
}
@Override
public byte[] getBytes() {
return bytes;
}
}
But when I switched everything to test TS.ADD, it's doesn't work even though I added additional args accordingly. e.g.
String result = syncCommands.dispatch(TS.ADD, new StatusOutput<>(codec),new CommandArgs<>(codec).addKey("myTS").addValue("1000001").addValue("2.199"));
Here is the exception from the run:
Exception in thread "main" io.lettuce.core.RedisException: java.lang.IllegalStateException
at io.lettuce.core.LettuceFutures.awaitOrCancel(LettuceFutures.java:129)
at io.lettuce.core.FutureSyncInvocationHandler.handleInvocation(FutureSyncInvocationHandler.java:69)
at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)
at com.sun.proxy.$Proxy0.dispatch(Unknown Source)
at MyRedisClient.main(MyRedisClient.java:72)
Sorry for seeing this so late. If you haven't already found a solution I had initially implemented RediSearch commands using the dynamic commands.
Full source: https://github.com/RediSearch/lettusearch/commit/567de42c147e0f07184df444cd1ae9798ae2514e