In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Redis's operation command for key
Del key1 key2... Keyn
Function: delete 1 or more keys
Return value: ignore the key that does not exist and return the number of key actually deleted
Rename key newkey
Function: give key a new key name
Note: if newkey already exists, the original value of newkey is overwritten
Renamenx key newkey
Function: rename key to newkey
Return: 1 for modification, 0 for no modification
Note: nx-- > not exists, that is, rename when newkey does not exist
Move key db
Redis 127.0.0.1 6379 [1] > select 2
OK
Redis 127.0.0.1 redis [2] > keys
(empty list or set)
Redis 127.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 redis [2] > get cc
"3"
(note: a redis process opens more than one database. 16 databases are opened by default, numbered from 0 to 15. If you want to open more databases, you can modify them from the configuration file.)
Keys pattern queries the corresponding key
In redis, fuzzy query key is allowed
There are three wildcards,?, []
: with any number of characters
?: with a single character
[]: a character 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 three 6379 > mset one 1 two 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) "two"
Redis 127.0.0.1 6379 > keys
1) "one"
2) "two"
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 eaw 6379 > keys on [eaw]
1) "one"
Randomkey returns random key
...
Exists key
To determine whether key exists or not, return 1 Universe 0
Type key
Returns the type of value stored in key
There's string,link,set,order set, hash.
Ttl key
Purpose: query the lifecycle of key
Return: seconds
Note: for key that does not exist or key that does not expire key/ that has expired,-1 is returned
In Redis2.8, for key that does not exist, return-2
Expire key integer value
Function: sets the life cycle of key in seconds
By the same token:
Pexpire key milliseconds, set lifecycle
Pttl key, which returns the life cycle in milliseconds
Persist key
Function: set the specified key to be permanent
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.