当前位置:网站首页>Redis string type
Redis string type
2022-07-06 01:40:00 【Freezing point contract】
String type :string
- String yes Redis Most basic types , You can understand that Memcached As like as two peas , One key Corresponding to one value;
- String Type is binary safe , signify Redis Of string Can contain any data . such as jpg Picture or serialized object
- String The type is Redis Basic data types , One Redis Middle string value At most 512M
Common commands
Add key value pair
set <key> <value>obtain key Corresponding value
get <key>Will specify value Append to original value At the end of
append <key> <value>obtain value The length of
strlen <key>Only when key When it doesn't exist key Add
setnx <key> <value>take key Increase the value of the number stored in 1, Can only operate on numeric values , If it is empty , The new value added is 1
incr <key>take key The number stored in minus 1, Can only operate on numeric values , If it is empty , The new value added is -1
decr <key>take key The numerical value stored in the custom step size increases or decreases
incrby <key> <step> decrby <key> <step>
The concept of atomic operation
- Atomic operations are operations that are not interrupted by the thread scheduling mechanism , Once this operation begins , It runs until the end , There won't be any context switch ( Switch to another thread )
- In a single thread , Operations that can be performed in a single instruction can be considered as " Atomic manipulation ", Because interrupts can only occur between instructions
- In multithreading , Can't be used by other processes ( Threads ) The interrupted operation is called atomic operation
- Redis The atomicity of a single command is mainly due to Redis The single thread
String batch operation command
At the same time for multiple key Set the value
mset <key1> <value1> <key2> <value2> ...Get multiple at the same time value
mget <key1> <key2> ...Set up multiple value, And key non-existent ( Atomicity : One existence fails )
msetnx <key1> <value1> <key2> <value2> ...
Other commands
Get substring , From the index start To stop( Left and right closed )
getrang <key> <start> <stop>Use... From the specified index location value Covering substring
setrang <key> <index> <value>Set the expiration time while setting the key value pair ( Company :s)
setex <key> <time> <value>To old change new ( Read original value , And write )
getset <key> <value>
String data structure

- String The data structure of is a simple dynamic string (Simple Dynamic String, abbreviation SDS). Is a string that can be modified , The internal structure is similar to Java Of ArrayList, Reduce the frequent allocation of memory by pre allocating redundant space
- Space actually allocated internally for the current string capacity Generally higher than the actual string length len. When the string length is less than 1M when , Expansion is to double the existing space , If exceeded 1M, When expanding, it will only expand more at one time 1M Space . Note that the maximum string length is 512M
边栏推荐
- Alibaba canal usage details (pit draining version)_ MySQL and ES data synchronization
- Force buckle 9 palindromes
- 1. Introduction to basic functions of power query
- leetcode刷题_平方数之和
- Ali test open-ended questions
- Paddle framework: paddlenlp overview [propeller natural language processing development library]
- 【全網最全】 |MySQL EXPLAIN 完全解讀
- UE4 unreal engine, editor basic application, usage skills (IV)
- 【SSRF-01】服务器端请求伪造漏洞原理及利用实例
- Accelerating spark data access with alluxio in kubernetes
猜你喜欢

A picture to understand! Why did the school teach you coding but still not

Ordinary people end up in Global trade, and a new round of structural opportunities emerge

Basic operations of databases and tables ----- unique constraints

【详细】快速实现对象映射的几种方式

leetcode刷题_平方数之和

leetcode刷题_反转字符串中的元音字母

3D vision - 4 Getting started with gesture recognition - using mediapipe includes single frame and real time video

Poj2315 football games

3D视觉——4.手势识别(Gesture Recognition)入门——使用MediaPipe含单帧(Singel Frame)和实时视频(Real-Time Video)
![[机缘参悟-39]:鬼谷子-第五飞箝篇 - 警示之二:赞美的六种类型,谨防享受赞美快感如同鱼儿享受诱饵。](/img/3c/ec97abfabecb3f0c821beb6cfe2983.jpg)
[机缘参悟-39]:鬼谷子-第五飞箝篇 - 警示之二:赞美的六种类型,谨防享受赞美快感如同鱼儿享受诱饵。
随机推荐
竞赛题 2022-6-26
Crawler request module
Loop structure of program (for loop)
Force buckle 1020 Number of enclaves
leetcode-2.回文判断
[ssrf-01] principle and utilization examples of server-side Request Forgery vulnerability
SPIR-V初窺
[le plus complet du réseau] | interprétation complète de MySQL explicite
[flask] official tutorial -part2: Blueprint - view, template, static file
Dynamics 365 开发协作最佳实践思考
500 lines of code to understand the principle of mecached cache client driver
How to see the K-line chart of gold price trend?
National intangible cultural heritage inheritor HD Wang's shadow digital collection of "Four Beauties" made an amazing debut!
[technology development -28]: overview of information and communication network, new technology forms, high-quality development of information and communication industry
Basic operations of database and table ----- set the fields of the table to be automatically added
【Flask】官方教程(Tutorial)-part1:项目布局、应用程序设置、定义和访问数据库
Ali test open-ended questions
leetcode-两数之和
Format code_ What does formatting code mean
UE4 unreal engine, editor basic application, usage skills (IV)