In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Commands for value operations
Exists (key): confirm whether a key exists
Del (key): delete a key
Type (key): type of return value
Keys (pattern): returns all key keys that satisfy a given pattern *
Randomkey: a key that randomly returns key space
Rename oldname newname: rename key from oldname to ranem age agf
Newname. Delete the key represented by newname if newname exists.
Dbsize: returns the number of key in the current database
Expire: set the active time of a key (s)
Ttl: get the active time of a key
Select (index): switch databases by index query) (0-15 of 16)
Move (key, dbindex): transfers the key in the current database to a dbindex index
Database of
Flushdb: deletes all key in the currently selected database
Flushall: delete all key in all databases
two。 Commands for String operations
Set (key, value): assigns the value value to the string named key in the database
Get (key): returns the value of the string named key in the database
Getset (key, value): give the string named key the old value of the last value display and the new value
Getrange gets a substring of the value value of the specified key.
127.0.0.1 purl 6379 > get name
"sad"
127.0.0.1 getrange name 6379 > 0 1
"sa"
127.0.0.1 purl 6379 > set name HongWan@126.com
Ok
127.0.0.1 purl 6379 > get name
"HongWan@126.com"
127.0.0.1Plus 6379 > getrange name-8-5
"@ 126"
Mget (key1, key2, … , key N): returns multiple string in the library whose names are
Key1,key2... Value of)
127.0.0.1 purl 6379 > mget name age love
1) "xiaoqin"
2) "11"
3) "wu"
Setnx (key, value): if there is no string named key, add it to the library
String, whose name is key and a value of value
127.0.0.1 purl 6379 > setnx qin qu
(integer) 1
127.0.0.1 purl 6379 > get qin
"qu"
Setex (key, time, value): add string (name key, value value) to the library
At the same time, set expiration time time
127.0.0.1 6379 > setex name 100 aiqu
OK
127.0.0.1 6379 > keys *
1) "home"
2) "name"
3) "six"
127.0.0.1 purl 6379 > get name
"aiqu"
Mset (key1, value1, key2, value2, … Key N, value N): give multiple at the same time
String assignment, string assignment value I named key I
127.0.0.1 purl 6379 > mset aa bb cc dd ee ff
OK
127.0.0.1 6379 > keys *
1) "aa"
2) "ee"
3) "cc"
Msetnx (key1, value1, key2, value2, … Key N, value N): if all
If a string with the name key I does not exist, string is added to the library with the name key I
Assigned to value I
Incr (key): string add 1 operation named key
127.0.0.1 purl 6379 > incr age
(integer) 12
127.0.0.1 purl 6379 > get age
Incrby (key, integer): string named key adds integer
127.0.0.1 incrby age 6379 > 1
(integer) 13
127.0.0.1 incrby age 6379 > 1
(integer) 14
127.0.0.1 incrby age 6379 > 1
(integer) 15
Decr (key): string minus 1 operation named key
127.0.0.1 purl 6379 > decr age
(integer) 14
127.0.0.1purl 6379 >
127.0.0.1 purl 6379 > decr age
(integer) 13
Decrby (key, integer): string named key reduces integer
Append (key, value): the value of the string named key is appended to value
127.0.0.1 purl 6379 > get age
"135"
127.0.0.1 6379 > append age 5
(integer) 4
127.0.0.1 purl 6379 > get age
"1355"
Substr (key, start, end): returns the substring of the value of string with the name key
3. Commands for List operations
Rpush (key, value): add an element with the value value to the end of the list named key
127.0.0.1 6379 > rpush hhh 2222 111 333
(integer) 3
127.0.0.1 6379 > keys *
1) "aa"
2) "hhh"
Lpush (key, value): add an element with a value of value to the list header named key
Llen (key): returns the length of the list named key
Lrange (key, start, end): returns the elements between start and end in the list named key (subscript starts with 0, same below)
127.0.0.1 lrange hhh 6379 > 0 0
1) "888"
127.0.0.1 lrange hhh 6379 > 0 1
1) "888"
2) "012"
127.0.0.1 lrange hhh 6379 > 0 2
1) "888"
2) "012"
3) "222"
Ltrim (key, start, end): intercepts the list named key and retains the elements between start and end
Lindex (key, index): returns the element of the index location in the list named key
127.0.0.1 lindex hhh 6379 > 0
"888"
127.0.0.1 lindex hhh 6379 > 1
"012"
127.0.0.1 lindex hhh 6379 >
"222"
Lset (key, index, value): assign value to the element of index position in the list named key
127.0.0.1 lset hhh 6379 > 0999
OK
127.0.0.1 lindex hhh 6379 > 0
"999"
127.0.0.1 lindex hhh 6379 > 1
"012"
Lrem (key, count, value): delete count list with the name key
Elements of value. If count is 0, delete all elements whose value is value, and count > 0 from the
Delete all elements with the value of count value from beginning to end, count lpop hhh
"012"
127.0.0.1 purl 6379 > lpop hhh
"222"
127.0.0.1 purl 6379 > lpop hhh
Rpop (key): returns and deletes the tail element in the list named key
127.0.1 6379 > rpush hhh 2222 111 333 444 555 666 777 888 999
(integer) 9
127.0.0.1 purl 6379 > rpop hhh
"999"
127.0.0.1 purl 6379 > rpop hhh
Blpop (key1, key2, … Key N, timeout): the block version of the lpop command. That is,
When timeout is 0, if a list named key I does not exist or the list is empty, the command
End. If timeout > 0, wait for timeout seconds when you encounter the above situation, if you ask
If the problem is not solved, the pop operation is performed on the list started by key iTunes 1.
Brpop (key1, key2, … Key N, timeout): the block version of rpop. Refer to
An order.
Rpoplpush (srckey, dstkey): returns and deletes the tail element of the list named srckey
Element and add it to the header of the list named dstkey
4. Commands for Set operations
Sadd (key, member): add the element member to the set named key
Srem (key, member): deletes the element member in the set named key
Spop (key): randomly returns and deletes an element in the set named key
Smove (srckey, dstkey, member): move member elements from a collection named srckey to a collection named dstkey
Scard (key): returns the cardinality of the set named key
Sismember (key, member): test whether member is an element of set named key
127.0.0.1 purl 6379 > sismember zz n
(integer) 0
127.0.0.1 purl 6379 > sismember zz b
(integer) 1
127.0.0.1 purl 6379 > sismember zz v
Sinter (key1, key2, … Key N): find the intersection
127.0.0.1 purl 6379 > sadd ss zz xx cc vv bb nn z x c v b n
(integer) 12
127.0.0.1 purl 6379 > sinter zz ss
1) "vv"
2) "x"
3) "cc"
4) "xx"
5) "bb"
6) "v"
7) "b"
8) "c"
Sinterstore (dstkey, key1, key2, … Key N): find the intersection and save the intersection to the collection of dstkey
127.0.0.1 purl 6379 > sinterstore dd zz ss
(integer) 8
127.0.0.1zz ss 6379 > smembers dd (dd is the intersection of zz ss)
1) "b"
2) "v"
3) "vv"
4) "c"
5) "x"
6) "cc"
7) "xx"
8) "bb"
Sunion (key1, key2, … Key N): Union set
127.0.0.1 purl 6379 > sunion zz ss
1) "vv"
2) "x"
3) "z"
4) "xx"
5) "cc"
6) "bb"
7) "n"
8) "zz"
9) "nn"
10) "v"
11) "b"
12) "c"
Sunionstore (dstkey, key1, key2, … Key N): join and save the union
Collection to dstkey
Sdiff (key1, key2, … Key N): difference set
127.0.0.1 purl 6379 > sdiff ss zz
1) "zz"
2) "nn"
3) "n"
4) "z"
Sdiffstore (dstkey, key1, key2, … Key N): compute and save the difference set to
Collection of dstkey
Smembers (key): returns all elements of a set named key
Srandmember (key): randomly returns an element of set with the name key
5. Commands for zset (sorted set) operations
Zadd (key, score, member): add the element member,score to the zset named key for sorting. If the element already exists, the order of the element is updated according to score.
It should be noted here that score must be an integer, not a character.
127.0.0.1 6379 > zadd qq 4 fore
(integer) 1
127.0.0.1 6379 > zadd qq 5 five
(integer) 1
127.0.0.1 6379 > zrange qq 0 2 withscores
1) "five"
2) "4"
3) "fore"
4) "5"
Zrem (key, member): deletes the element member in the zset named key
127.0.0.1 purl 6379 > zrem qq five
(integer) 1
127.0.0.1 6379 > zrange qq 0 2 withscores
1) "fore"
2) "4"
Zincrby (key, increment, member): if in a zset named key
After the existence of the element member, the score of the element increases increment; otherwise to the collection
Add this element in, and its score value is increment
127.0.0.1 6379 > zrange qq 0 2 withscores
1) "fore"
2) "4"
127.0.0.1 6379 > zincrby qq 2 fore
"6"
127.0.0.1 6379 > zrange qq 0 2 withscores
1) "fore"
2) "6"
Zrank (key, member): returns a zset with the name key (the element has been reduced by score
The rank of the member element in the big sort (that is, index, starting with 0), if there is no member
Element, returning "nil"
Zrevrank (key, member): returns a zset with the name key (element has been pressed score
The rank (that is, index, starting with 0) of the member element in the order from largest to smallest, if not
Member element, which returns "nil"
Zrange (key, start, end): returns a zset with the name key (the element has been downloaded from the
All elements of index from start to end in small to large sort
Zrevrange (key, start, end): returns a zset with the name key (the element has been pressed score
All elements of index from start to end in order from largest to smallest
Zrangebyscore (key, min, max): returns the zset with the name key
Score > = min and score = min and rank = min and score hset www qwqw klk
(integer) 1
Hget (key, field): returns the value corresponding to field in the hash named key
127.0.0.1 purl 6379 > hget www qwqw
"klk"
Hmget (key, field1, … , field N): returns the value corresponding to field I in the hash named key
127.0.0.1 purl 6379 > hmset www qqq aaa eee ddd rrr fff ttt ggg yyy hhh
OK
127.0.0.1 purl 6379 > hmget www qwqw qqq eee rrr ttt hhh
1) "klk"
2) "aaa"
3) "ddd"
4) "fff"
5) "ggg"
6) (nil)
Hmset (key, field1, value1, … , field N, value N): add the element field ivalue i to the hash named key
127.0.0.1 purl 6379 > hmset www uuu jjj
OK
127.0.0.1 purl 6379 > hmget www qwqw qqq eee rrr ttt hhh uuu
1) "klk"
2) "aaa"
3) "ddd"
4) "fff"
5) "ggg"
6) (nil)
7) "jjj"
Hincrby (key, field, integer): add integer to the value of field in the hash named key
127.0.0.1 hmset www iii 6379 >
OK
127.0.0.1 hincrby www iii 6379 >
(integer) 333
127.0.0.1 purl 6379 > hget www iii
"333"
Hexists (key, field): whether there is a domain with the key field in the hash named key
127.0.0.1 purl 6379 > hexists www eee
(integer) 1
Hdel (key, field): delete the domain with the key field in the hash named key
127.0.0.1 purl 6379 > hexists www eee
(integer) 1
127.0.0.1 purl 6379 > hdel www eee
(integer) 1
127.0.0.1 purl 6379 > hexists www eee
(integer) 0
Hlen (key): returns the number of elements in a hash named key
127.0.0.1 purl 6379 > hlen www
(integer) 7
Hkeys (key): returns all keys in the hash with the name key
127.0.0.1 purl 6379 > hkeys www
1) "qwqw"
2) "qqq"
3) "rrr"
4) "ttt"
5) "yyy"
6) "uuu"
7) "iii"
Hvals (key): returns the value of all keys in the hash named key
127.0.0.1 purl 6379 > hkeys www
1) "qwqw"
2) "qqq"
3) "rrr"
4) "ttt"
5) "yyy"
6) "uuu"
7) "iii"
127.0.0.1 purl 6379 > hvals www
1) "klk"
2) "aaa"
3) "fff"
4) "ggg"
5) "hhh"
6) "jjj"
7) "333"
Hgetall (key): returns all keys (field) and their corresponding value in the hash named key
127.0.0.1 purl 6379 > hgetall www
1) "qwqw"
2) "klk"
3) "qqq"
4) "aaa"
5) "rrr"
6) "fff"
7) "ttt"
8) "ggg"
9) "yyy"
10) "hhh"
11) "uuu"
12) "jjj"
13) "iii"
14) "333"
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.