当前位置:网站首页>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
边栏推荐
- [solved] how to generate a beautiful static document description page
- SPIR-V初窥
- Poj2315 football games
- Paddle框架:PaddleNLP概述【飛槳自然語言處理開發庫】
- Ordinary people end up in Global trade, and a new round of structural opportunities emerge
- Redis-字符串类型
- Docker compose configures MySQL and realizes remote connection
- c#网页打开winform exe
- 国家级非遗传承人高清旺《四大美人》皮影数字藏品惊艳亮相!
- Mathematical modeling learning from scratch (2): Tools
猜你喜欢

【Flask】官方教程(Tutorial)-part3:blog蓝图、项目可安装化

Docker compose configures MySQL and realizes remote connection
![[ssrf-01] principle and utilization examples of server-side Request Forgery vulnerability](/img/43/a8f302eb69beff4037aadda808f886.png)
[ssrf-01] principle and utilization examples of server-side Request Forgery vulnerability

Leetcode skimming questions_ Sum of squares

MySQL learning notes 2

2022年PMP项目管理考试敏捷知识点(8)

Docker compose配置MySQL并实现远程连接

Basic operations of database and table ----- delete data table
![[Jiudu OJ 09] two points to find student information](/img/35/25aac51fa3e08558b1f6e2541762b6.jpg)
[Jiudu OJ 09] two points to find student information

2022 PMP project management examination agile knowledge points (8)
随机推荐
2022年广西自治区中职组“网络空间安全”赛题及赛题解析(超详细)
leetcode刷题_验证回文字符串 Ⅱ
[ssrf-01] principle and utilization examples of server-side Request Forgery vulnerability
How to upgrade kubernetes in place
Initialize MySQL database when docker container starts
[技术发展-28]:信息通信网大全、新的技术形态、信息通信行业高质量发展概览
Unity | two ways to realize facial drive
[Yu Yue education] Liaoning Vocational College of Architecture Web server application development reference
A Cooperative Approach to Particle Swarm Optimization
Electrical data | IEEE118 (including wind and solar energy)
NumPy 数组索引 切片
[network attack and defense training exercises]
What is weak reference? What are the weak reference data types in ES6? What are weak references in JS?
selenium 等待方式
How to see the K-line chart of gold price trend?
2 power view
Alibaba canal usage details (pit draining version)_ MySQL and ES data synchronization
[le plus complet du réseau] | interprétation complète de MySQL explicite
Leetcode3. Implement strstr()
[flask] official tutorial -part2: Blueprint - view, template, static file