Search code examples
javaredisjedis

Delete multiple Redis stream id with Jedis


how can i delete multi redis stream id with jedis?

they have a methods calls "xdel" -

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

what is the type that i need to send to the method to delete multi key? i declare List but the method didnt get this type.

i got this error -

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)

Solution

  • Jedis xdel method takes varags of StreamEntryID. So you can do only following two:

    1.

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

    But you're sending Stream of StreamEntryID. You can consider changing your Stream (Stream<StreamEntryID>) to array (StreamEntryID[]).