【问题标题】:Delete multiple Redis stream id with Jedis使用 Jedis 删除多个 Redis 流 id
【发布时间】:2022-01-05 13:28:27
【问题描述】:

如何使用 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)

【问题讨论】:

    标签: java redis jedis


    【解决方案1】:

    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&lt;StreamEntryID&gt;) 更改为数组 (StreamEntryID[])。

    【讨论】:

      猜你喜欢
      • 2014-02-14
      • 2019-03-19
      • 2022-10-01
      • 2017-04-02
      • 1970-01-01
      • 1970-01-01
      • 2017-03-30
      • 1970-01-01
      • 2020-10-13
      相关资源
      最近更新 更多