Я пытаюсь импортировать RedisStreamCommands
.Мне было разрешено импортировать его, но я могу импортировать RedisCommands.Я думаю, что это нуждается в зависимости.Я не знаю, что это было, пожалуйста, помогите мне.
RedisCommands<String, String> syncCommands = connection.sync();
RedisStreamCommands<String, String> streamCommands = connection.sync();
syncCommands.set("key_1", "Hello, Redis!");
Map<String, String> body = Collections.singletonMap("key", "value");
String messageId = streamCommands.xadd("my-stream", body);
Я пробовал вот так: было показано сообщение об ошибке на RedisStreamCommands.
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisURI;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.sync.*;
import io.lettuce.core.api.sync.RedisCommands;
import io.lettuce.core.cluster.RedisClusterClient;
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection;
import io.lettuce.core.cluster.api.sync.RedisAdvancedClusterCommands;
public class LettuceDemo {
public static void main(String[] args) {
RedisClient redisClient = RedisClient.create("redis://15m4madm4bd6ypfqtc353wfq4q292brk@expeditious-ironwood-6027.redisgreen.net:11042/0");
StatefulRedisConnection<String, String> connection = redisClient.connect();
RedisCommands<String, String> syncCommands = connection.sync();
RedisStreamCommands<String, String> streamCommands = connection.sync();
syncCommands.set("key_1", "Hello, Redis!");
Map<String, String> body = Collections.singletonMap("key", "value");
String messageId = streamCommands.xadd("my-stream", body);
connection.close();
redisClient.shutdown();
}
}