使用 Jedis 删除多个 Redis 流 ID

Delete multiple Redis stream id with Jedis

如何使用jedis删除多个redis流id?

他们有一个名为“xdel”的方法 -

xdel(String key, StreamEntryID... ids)
XDEL key ID [ID ...]

我需要发送到删除多键的方法的类型是什么? 我声明了 List 但方法没有得到这种类型。

我收到这个错误 -

method redis.clients.jedis.Jedis.xdel(java.lang.String,redis.clients.jedis.StreamEntryID...) is not applicable
      (varargs mismatch; java.util.stream.Stream<redis.clients.jedis.StreamEntryID> cannot be converted to redis.clients.jedis.StreamEntryID)

Jedis xdel 方法采用 StreamEntryID 的可变参数。所以你只能做以下两个:

1.

String key;
StreamEntryID id1, id2, ..., idN;
...
jedis.xdel(key, id1, id2, ..., idN);
String key;
StreamEntryID[] ids;
...
jedis.xdel(key, ids);

但是您正在发送 StreamEntryID 的 Stream。您可以考虑将流 (Stream<StreamEntryID>) 更改为数组 (StreamEntryID[]).