redis-cli keys "*" | xargs redis-cli del //If redis-cli is not set as a system variable, you need to specify the full path of redis-cli //如:/opt/redis/redis-cli keys "*" | xargs /opt/redis/redis-cli del
If you want to specify the Redis database access password, use the following command
redis-cli -a password keys "*" | xargs redis-cli -a password del
If you want to access a specific database in Redis, use the following command
//The following command specifies that the data serial number is 0, which is the default database redis-cli -n 0 keys "*" | xargs redis-cli -n 0 del
To delete all keys, you can use the flushdb and flushall commands of Redis
// delete all keys in the current database flushdb // delete all keys in the database flushall
Expiration time, if it has been set, then update the expiration time
expire key seconds
View remaining time
ttl key