如何实时从redis获取最新数据?
我想用Redis实现实时应用程序 Redis上有实时推送的数据,如下面使用该库的源代码如何实时从redis获取最新数据?,redis,lettuce,Redis,Lettuce,我想用Redis实现实时应用程序 Redis上有实时推送的数据,如下面使用该库的源代码 RedisClient redisClient = RedisClient.create(uri); StatefulRedisConnection<String, String> connection = redisClient.connect() RedisStringAsyncCommands<String, String> asyncCommands = connectio
RedisClient redisClient = RedisClient.create(uri);
StatefulRedisConnection<String, String> connection = redisClient.connect()
RedisStringAsyncCommands<String, String> asyncCommands = connection.async();
List<RedisFuture<?>> futures = Lists.newArrayList();
while(true) {
futures.add(asyncCommands.set("key", "value"));
}
RedisClient=RedisClient.create(uri);
StatefulRedisConnection=redisClient.connect()
RedistringAsyncCommands asyncCommands=connection.async();
列表您可以尝试[Redis Stream[()以及streams您也可以尝试Thx,我将尝试。
while(true) {
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
for (ConsumerRecord<String, String> record : records) {
logger.info("offset = {}, value = {}", record.offset(), record.value());
}
}