Del key1 Key2 ... Keyn
Action: Delete 1 or more keys
Return value: The nonexistent key is ignored, returning the number of really deleted keys
Rename Key Newkey
Function: Assign a new key name to the key
Note: If Newkey already exists, the original value of Newkey is overwritten
Function: Rename key to Newkey
Return: The modification returned 1, no modification returned 0
Note: Nx--> not exists, that is, when Newkey does not exist, make a name change action
Move Key db
Redis 127.0.0.1:6379[1]> Select 2
Ok
Redis 127.0.0.1:6379[2]> Keys *
(empty list or set)
Redis 127.0.0.1:6379[2]> Select 0
Ok
Redis 127.0.0.1:6379> Keys *
1) "Name"
2) "CC"
3) "A"
4) "B"
Redis 127.0.0.1:6379> Move cc 2
(integer) 1
Redis 127.0.0.1:6379> Select 2
Ok
Redis 127.0.0.1:6379[2]> Keys *
1) "CC"
Redis 127.0.0.1:6379[2]> Get CC
"3"
(Note: A Redis process that opens more than one database, opens 16 databases by default, numbering from 0 to 15 , can be modified from a configuration file if you want to open more databases)
Keys pattern query the corresponding key
In Redis, allow fuzzy query key
There are 3 wildcard characters *,? ,[]
*: Wildcard with any number of characters
?: Pass a single character
[]: 1 characters in parentheses
Redis 127.0.0.1:6379> Flushdb
Ok
Redis 127.0.0.1:6379> Keys *
(empty list or set)
Redis 127.0.0.1:6379> Mset One 1 2 three 3 four 4
Ok
Redis 127.0.0.1:6379> Keys o*
1) "One"
Redis 127.0.0.1:6379> Key *o
(Error) ERR unknown command ' key '
Redis 127.0.0.1:6379> Keys *o
1) "Both"
Redis 127.0.0.1:6379> Keys???
1) "One"
2) "Both"
Redis 127.0.0.1:6379> keys on?
1) "One"
Redis 127.0.0.1:6379> Set ONS yes
Ok
Redis 127.0.0.1:6379> Keys ON[EAW]
1) "One"
Randomkey return random Key
Exists key
Determine if key exists, return 1/0
Type key
Returns the type of value stored by key
Have String,link,set,order set, hash
TTL key
Role: Querying the life cycle of a key
Return: Number of seconds
Note: For nonexistent key or expired key/key, all returns-1
Redis2.8, for a nonexistent key, return-2
Expire key Integral type value
Function: Sets the lifecycle of a key in seconds
Similarly:
Pexpire key milliseconds, setting life cycle
Pttl key, returns the life cycle in milliseconds
Persist key
Function: The specified key is permanently active
Redis action command for key