In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use strings in Redis", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to use strings in Redis" this article.
Redis is stored in the data structure of key value, each key is unique, the string is the simplest data structure in redis, its interior is actually an array of characters.
The string in redis is a dynamic character array, similar to arrayList in Java. Pre-allocation redundancy is used to reduce frequent memory allocation. The actual space capacity allocated for the current string is generally higher than the actual string length len. When the string length is less than 1MB, the expansion doubles the existing space. If the length of the string exceeds 1MB, only the space of 1MB will be expanded at one time, and the maximum length of the string is 512MB.
Let's try some common commands.
> set name mangoOK > get name mango "mango" > exists name (intgeter) > del name (intgeter) > get name (nil)
Batch processing
> mset name1 mango name2 loveOK > mget name1 name21) "mango" 2) "love"
Postpone
> set name mangoOK > get name "mango" > expire name 5.5s later > get name (nil)
> setex name 5 mango # 5s expires, which is equivalent to set+exp worker re > get name "mango"... 5s later > get name (nil)
> setnx name mango # if name does not exist, execute set (integer) 1 > get name "mango" > setnx name love (integer) 0 # because name already exists, so set creation is not successful # if name does not exist, execute set creation > get name "mango" # the value has not changed
Count
If value is an integer, you can perform a self-incrementing operation, and if the self-incrementing range signed long is between the maximum and minimum values, Redis will report an error if it exceeds this range.
> set age 18OK > incr age (integer) 19 > incrby age 2 (integer) 21 > incrby age-2 (integer) 19 > set codemax 9223372036854775807OK > incr codemax (error) ERR increment or decrement would overflow are all the contents of this article "how to use strings in Redis". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.