Operation key method in redis

To connect use:

redis-cli -h [ip address, if it is the local machine, it can be ignored, (no need to add -h)] -p [port number, default 6379] -a [enter the password if there is a password, if not, ignore it, (no need to add -a)]
After connecting, input ping to test whether the connection is successful

Example: redis-cli -h 127.0.0.1 -p 6379 -a xxxx (xxxx is the password)

ping

Return PONG proxy connection success!

Delete processing:

1. To delete all keys, you can use redis's own commands:

flushdb deletes all keys in the current database

flushall deletes all keys in the database

2. Use xargs in linux to delete all keys

redis-cli keys “*” | xargs redis-cli del

3. Delete the key containing certain keywords

redis-cli keys “xxx*” | xargs redis-cli del

4. If you need to specify a password, you can use it like this:

redis-cli -a pwd keys “*” | xargs redis-cli -a pwd del

Guess you like

Origin blog.csdn.net/tiging/article/details/127550176