简体   繁体   中英

java jedis for Redis

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)

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[] ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM