Redis Common Commands
Redis provides rich commands for manipulating databases and various database types, which can be used in LinuxTerminal use
1. Key-Value related commands
2. Server-related commands
key-Value related commands
keys Pattern Example: Keys *
returns all keys that satisfy a given pattern
exists
confirm if a key exists
del
Delete a key
expire
set the expiration time for a key
Example: Expire addr 10 (time ten s)
ttl addr (use TTL to get the effective duration of addr)
returns-1, expired
Move moves the key in the current database to another database
Select Database
Select 0 (where 0 represents the first database)
command: (move the age of database 0 to database 1)
Select 0
Move age 1
Select 1
Get Age
persist
Remove the expiration time for a given key
command:
expire Age
persist Age
Randomkey
randomly returns a key in the key space
Rename
Rename key
Rename Age age_new
type
type of return value
server-related commands
Ping
Test If the connection is alive
Select
Select database, redis database number 0~15, we can select any database to
access to the data
quit
Exit Connection
dbsize
returns the number of keys in the current database
Info
get information and statistics for the server
Config Get
real-time upload of received requests
Flushdb
Delete all keys in the currently selected database
Flushall
remove all keys from all databases
Redis Learning (5)-Common commands