Deleting multiple keys through one command

600 views
Skip to first unread message

Santos Das

unread,
Jun 7, 2017, 10:57:51 AM6/7/17
to Redis DB
Hi,

I am using Redis cluster. How can I delete the multiple keys through one single command.

Any help?

Itamar Haber

unread,
Jun 7, 2017, 11:29:33 AM6/7/17
to Redis DB
As long as your keys are in the same hash slot, you can use `DEL` or v4's `UNLINK` regularly. If your keys belong to different slots, group them by slot and then use the same. IIRC, some Redis clients with Cluster support feature helpers for that purpose. 

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Santos Das

unread,
Jun 7, 2017, 11:56:56 AM6/7/17
to Redis DB
Thank you Itamar.

Is there a way I can force the all my keys to be in same hash slot?

Also, are you aware of the client which supports this.

I am using hiredis-vip.'

Thanks, Santos

Itamar Haber

unread,
Jun 7, 2017, 12:09:13 PM6/7/17
to Redis DB
You can use hash tag for grouping keys in a slot - read about it at https://redis.io/topics/cluster-spec#keys-hash-tags.

I believe it was one (or both?) of the popular ones for Java - Jedis and Lettuce - but I may be mistaken.

hva...@gmail.com

unread,
Jun 7, 2017, 12:31:24 PM6/7/17
to Redis DB
If you're asking about ALL the keys in the database, then you can use the FLUSHDB command to delete them.  If you want to delete some keys and leave the rest in the database, then you don't want to use FLUSHDB.

Santos Das

unread,
Jun 7, 2017, 12:51:59 PM6/7/17
to Redis DB
Thanks Itamar.....I will look at hash tags..

On Wednesday, June 7, 2017 at 8:27:51 PM UTC+5:30, Santos Das wrote:
Reply all
Reply to author
Forward
0 new messages