In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Five data types string (string) commonly used operations 127.0.0.1 string 6379 > get name (nil) 127.0.0.1 nil 6379 > set name Test OK127.0.0.1:6379 > get name "\ xe6\ xb5\ x8b\ xe8\ xaf\ x95" 127.0.0.1OK127.0.0.1:6379 6379 > exists name (integer) 1127.0.0.1Ze6379 > del name (integer) 1127.0.0.1 > get name (nil) 127.0.1 > mset Name1 ceshi1 name2 ceshi2 # batch setOK127.0.0.1:6379 > mget name1 name2 # batch get1) "ceshi1" 2) "ceshi2" 127.0.0.1 get1 6379 > expire name1 10 # set expiration time (integer) 1127.0.0.1 mget name1 name2 # set value and set expiration time OK127.0.0.1:6379 > ttl name1 # View expiration time (integer) -2127.0.0.1 setnx name4 ceshi4 6379 > set value This value returns 0 if it exists. Will not overwrite the original value (integer) 1127.0.0.1 integer 6379 > setnx name4 ceshi4 (integer) 0127.0.0.1 integer 6379 > incr age # + 1 (integer) 11127.0.0.1 integer 6379 > incrby age 10 # + n (integer) 21127.0.0.1 list 6379 > incrby age 5 (integer) 26 after the application scenario user information list (list) common operations 127.0.1 list > rpush yuyan java python php (integer) 3127 .0.0.1: 6379 > llen yuyan # list length (integer) 3127.0.0.1 lpop yuyan 6379 > lpop yuyan "java" 127.0.0.1 lpop yuyan 6379 > rpop yuyan "php" 127.0.0.1 java 6379 > lrange yuyan 0 1 # range lookup 1) queue data structure of "python" application scenario
It is a linked list, not an array, insert and delete operations are very fast, time complexity O (1), search is very slow
Hash (dictionary) commonly used operations: 127.0.0.1 hash 6379 > hset user_1 name xiaoli (integer) 1127.0.0.1 integer 6379 > hset user_1 age 12 (integer) 1127.0.0.1 integer 6379 > hgetall user_11) "name" 2) "xiaoli" 3) "age" 4) "12" 127.0.0.1 hset user_1 age 6379 > hget user_1 name "xiaoli" 127.0.0.1 > hlen user_1 (integer) 2127.0.0. 1RV 6379 > hmset user_2 name xiaowang age 13OK127.0.0.1:6379 > hincrby user_2 age 2 (integer) 15 Application scenarios store user information in multiple dimensions Name Age and other set (collections) commonly used operations 127.0.0.1 sadd userid 6379 > sadd userid 3 (integer) 1127.0.0.1 sadd userid 6379 > sadd userid 3 4 6 6 # add multiple (integer) 3127.0.0.1 sadd userid 6379 > smembers userid1) "3" 2) "4" 3) "5" 4) "6" 127.0.0.1 sadd userid 6 # contains (integer) 1127.0.1 0.1 integer ) 0127.0.0.1 scard userid # length (integer) 4127.0.0.1 spop userid # out 1) "5" 2) 3 "127.0.0.1 spop userid 6379 > smembers userid1)" 4 "2)" 6 "application scenario
Store the list of winning users, with deduplication function
Zset (ordered set) commonly used operations 127.0.0.1 user_2 50 user_3 20 user_4 (integer) 4127.0.1 user_1 length (integer) 4127.0.1 score 1) user_4 2) "user_3" 3) "user_1" 4) "user_2" 127.0.0.1: 6379 > zrevrange ranklist 0-1 # in reverse score order 1) "user_2" 2) "user_1" 3) "user_3" 4) "user_4" 127.0.0.1 score 6379 > zscore ranklist user_4 # get score value "20" 127.0.0.1 score 6379 > zscore ranklist user (nil) 127.0.0.1 score 6379 > zrangebyscore ranklist 20 30 # filter by score value 1) "user_4" 127.0.0.1 score # inf infinity Withscores returns a score value of 1) "user_3" 2) "50" 3) "user_1" 4) "1005)" user_2 "6)" 200127.0.0.1) zrem ranklist user_1 # delete (integer) 1 application scenario fan list, value is fan id,score is follow time, you can rank points by follow time, value is user id,score is points student score, value is student score is score.
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.