keys pattern query corresponding key in Redis, allow Fuzzy query key has 3 wildcard characters*, ? ,[]*: Wildcard with any number of characters?: Wildcard single character []: wildcard 1 characters in parentheses Redis127.0.0.1:6379>Flushdbokredis127.0.0.1:6379> Keys *//Check All(empty list or set) Redis127.0.0.1:6379> Mset One 1 2 three 3 four 4Okredis127.0.0.1:6379> keys o*1) "One"Redis127.0.0.1:6379> keys *o1) "Both"Redis127.0.0.1:6379> Keys??? 1) "One" 2) "one"Redis127.0.0.1:6379> keys on?1) "One"Redis127.0.0.1:6379>Set ONS yesokredis127.0.0.1:6379>Keys ON[EAW]1) "One"
Randomkey return random key (draw, haha)127.0.0.1:6379> randomkey"three"
the Type key returns the value stored by key with String,link,set,order set, hash127.0.0.1:6379> type onestring
exists key determines if key exists, returns 1/0127.0.0.1:6379>1127.0.0.1:6379>0
del key1 Key2 ... Keyn Effect: Delete 1 or more key return values: The nonexistent key is ignored, returning the number of really deleted keys 127.0.0.1:6379>1
Rename key Newkey function: Give key a new key name note: If Newkey already exists, then Newkey's original value is overwritten 127.0.0.1:6379>127.0.0.1:6379 >0127.0.0.1:6379>1
Redis 127.0.0.1:6379> Set Site "www.baidu.com"
Ok
Redis 127.0.0.1:6379> Set Search "www.sohu.com"
Ok
Redis 127.0.0.1:6379> Rename Site search
Ok
Redis 127.0.0.1:6379> Get Search
"Www.baidu.com"-------the original value of search is overwritten
Renamenx key Newkey function: Rename key to Newkey return: change occurred return 1, no modification returned 0 Note: nx--> NOT exists, that is, Newkey does not exist, Newkey does not exist, change, exist, do not change the name of the action
default database is DB 0, you can select# a different one on a per-connection basis using Select <DBI D>0 and ' databases '-1Redis opens 16 databases by default, number 0-15127.0.0.1:6379> keys *) " Site "127.0.0.1:6379> Select 1127.0.0.1:6379[1]> keys *Select 0 127.0.0.1:6379> Keys *) "Site"
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
(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)
move key db127.0.0.1:6379> keys *) "site" 2) "Search"127.0.0.1:6379> Move site 11 /c5>127.0.0.1:6379> keys) "Search"127.0.0.1:6379> Select 1127.0.0.1:6379[1]> keys *) " Site
ttl key function: Query Key's life cycle return: seconds Note: For nonexistent key or expired key/key, return-1 redis2.8, for a nonexistent key, returns the -2redis 127.0.0.1:6379> TTL search (integer) -1
expire Key integer value: Sets the lifetime of the key, in seconds: Pexpire key milliseconds, sets the lifecycle Pttl key, returns the life cycle in milliseconds 127.0.0.1:6379> -1127.0.0.1:6379> expire Search 51127.0.0.1:6379> get Search" www.google.com "127.0.0.1:6379>127.0.0.1:6379>-1
127.0.0.1:6379>0
Redis Universal operation (for String,hash, linked lists, etc.)