Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove keys?

I want to remove keys that match "user*".

How do I do that in redis command line?

like image 602
TIMEX Avatar asked Jan 10 '12 05:01

TIMEX


People also ask

How do I remove keys without damaging them?

For desktop keyboards, take a butter knife or a screwdriver and try to pry up one corner of the keys. You don't need to use a lot of force; you should feel a pop and the key will come right off. For laptop keyboards, your fingernail should be enough to pull the plastic up.

How do you take off keyboard keys by hand?

Simply take a paper clip, unfold it into a straight line, and then make an L shape. Then all you need to do is slide it under a keycap and then lift. The keycap should pop right off. It's not perfect and may need to be reformed many times before all your keys are pulled, but it's super simple.

Can you remove keys from laptop?

What you need to remove laptop keys. While you can purchase keyboard key removal tools, you can also easily remove laptop keys using a flat head screwdriver. When cleaning your laptop keys, all you will need is some compressed air, rubbing alcohol, and cotton swabs.


3 Answers

Another compact one-liner I use to do what you want is:

redis-cli KEYS "user*" | xargs redis-cli DEL
like image 158
user1151446 Avatar answered Oct 20 '22 23:10

user1151446


This is not a feature right now to be able to do in one shot (see the comments in the DEL documentation). Unfortunately, you are only left with using KEYS, looping through the results, and then using DEL to remove each one.

How about using bash a bit to help?

for key in `echo 'KEYS user*' | redis-cli | awk '{print $1}'`
 do echo DEL $key
done | redis-cli

To step through it:

  1. echo 'KEYS user*' | redis-cli | awk '{print $1}' -- get all the keys and strip out the extra text you don't want with awk.
  2. echo DEL $key -- for each one, create an echo statement to remove it.
  3. | redis-cli -- take the DEL statements and pass them back into the cli.

Not suggesting this is the best approach (you might have some issues if some of your usernames have spaces in them, but hopefully you get the point).

like image 61
Donald Miner Avatar answered Oct 20 '22 21:10

Donald Miner


Now there is a command to remove a key,i.e., DEL key [keys]

DEL key...

like image 18
Narendra Chamoli Avatar answered Oct 20 '22 21:10

Narendra Chamoli