In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "the basic introduction of Redis string String". In daily operation, I believe many people have doubts about the basic introduction of Redis string String. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "basic introduction of Redis string String". Next, please follow the editor to study!
Redis string (String)
Single value single value
1. Basic method set/get/del/append/strlen
Append: append
Strlen: find the length
127.0.0.1 set K4 v3OK127.0.0.1:9736 > get K4 "v3" 127.0.0.1 V3) 9736 > append K4 55555 (integer) 7127.0.0.1 get 9736 > strlen K4 (integer) 7127.0.1 get 9736 > get K4 "v355555" 127.0.0.1 get 9736 > del K4 (integer) 1127.0.0.1 Swiss 9736 > keys * 1) "K2" 2) "K3" 127.0.0.1 VR 9736 > 2 incr/decr/incrby/decrby.
It must be a number in order to add or subtract.
Incr key: plus 1
Decr key: minus 1
Incrby key num: incremented according to num
Decrby key num: decrement according to num
127.0.0.1 get K4 "2" 127.0.0.1 integer > get K4 "3" 127.0.1 integer > decr K4 (integer) 2127.0.1 1 > get K4 "2" 127.0.1 DECRBY (integer) 1127.0.1 > DECRBY K4 "4 (integer) 1127.0.0 1 9736 > get K4 "1" 127.0.0.1 9736 > 3.
Take value within range, assign value within range
Getrange: gets values within a specified range, similar to between.and, and identifies all values from zero to minus one
Setrange: sets the value within the specified range. The format is setrange key location specific value.
127.0.0.1 set K5 123456OK127.0.0.1:9736 > get K5 "123456" 127.0.0.1 get 9736 > GETRANGE K50 3 "1234" 127.0.1 get 9736 > SETRANGE K5 455555 (integer) 9127.0.1 get 9736 > get K5 "123455555" 127.0.1 get 9736 > getrange K50-1 "123455555" 127.0.1 "9736 > get k50 xxx (integer) 9127.0.1 > get K5" xxx455555 "4. Setex (set with expire) key second value / setnx (set if not exist)
Set the expiration time while setting the setex value
Setnx if the value does not exist, it is set, and if it exists, it is not set and not overwritten.
127.0.0.1 SETEX K6 5OK127.0.0.1:9736 > ttl K6 (integer) 2127.0.0.1 ttl 9736 > ttl K6 (integer)-2127.0.0.1 ttl 9736 > keys * 1) "K2" 2) "K4" 3) "K5" 4) "K3" 127.0.0.1 ttl 9736 > 127.0.1V666 (integer) 1127.0.1V636 > get K6 "v666" v666 "127.0.0.1Switzerland 9736 > 5 mset/mget/msetnx.
Mset batch setup
Mget batch acquisition
Msetnx batch setting key that does not exist
127.0.0.1 mset 9736 > mget K1 v1 v2 v2 K3 v3OK127.0.0.1:9736 > mget K1 K2 K31) "v1" 2) "v2" 3) "v3" 127.0.1) V3 V3 v33 k4 v4 k5 v5 (integer) 0127.0.1 mget 9736 > mget K3 K4 k51) "v3" 2) "1" 3) "xxx455555" 127.0.1) 9736 > 6. Getset (first get then set)
Getset (first get and then set)
127.0.0.1 getset 9736 > Redis K6 v5 "v666" 127.0.1 V5 "get K6" v5 "127.0.0.1 V5" 127.0.0.1 V5 9736 > this is the end of the study on "basic introduction to Redis string String". I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.