当前位置:网站首页>SDS understanding in redis
SDS understanding in redis
2022-06-30 03:26:00 【Allianz love learning】
1.C In language char* What's the problem ?
- Will '/0' As the terminator of a string , So you can't store '/0' character .
- len(String) Operation requires O(n) Time complexity of .
- strcat(des,src) When you add it , Will traverse to des The end is being appended , High time complexity .
- char* Memory alignment is used by default , Wasted memory space .
2.Redis Customize SDS Reading ?
- SDS:Simple Dynamic String, Simple dynamic String, Be similar to Go Medium slice. The data structure is shown below :

2.SDS Store the length of the actual string and the actual memory size , It can be more convenient len() And string 、
3.struct __attribute__ ((__packed__)) Storage in a compact way can save memory space ,flags Used to mark the length used for storage . Here is flags=sdshdr8 Data structure of .
struct __attribute__ ((__packed__)) sdshdr8 { uint8_t len; /* The existing length of the character array */ uint8_t alloc; /* Allocated space for character array , Excluding structures and \0 End character */ unsigned char flags; /* SDS type */ char buf[]; /* A character array */ };边栏推荐
- Principle of device driver
- 【微信小程序】条件渲染 列表渲染 原来这样用?
- 数据库的下一个变革方向——云原生数据库
- Use common fileUpload to upload files
- 1150_ Makefile learning_ Duplicate name target processing in makefile
- 1148_ Makefile learning_ Targets, variables, and wildcards in makefile
- 如何实现远程协同办公,收好这份攻略!
- Note: load the configuration file as a byte stream and get the resources in it
- 通用分页(2)
- A GPU approach to particle physics
猜你喜欢
随机推荐
Use common fileUpload to upload files
[wechat applet] how did the conditional rendering list render work?
Reasons for MySQL master-slave database synchronization failure
QT中foreach的使用
laravel9本地安装
Differences between comparable and comparator
QT中foreach的使用
Local, locallow and roaming in the appdata folder
共124篇!墨天轮“高可用架构”干货文档分享(含Oracle、MySQL、PG)
Openssl3.0 learning 22 provider decoder
Shell counts all strings before the last occurrence of a string
专升本高数(四)
Mysql性能优化(6):读写分离
Sorting method of administrative route code letter + number
Dripping backward (II)
Auto. JS learning notes 15:ui interface basics of autojs Chapter 2
Stc89c52/90c516rd/89c516rd DHT11 temperature and humidity sensor drive code
Huawei interview question: divide candy
Simple custom MVC
Auto. JS learning notes 16: save to the mobile phone by project, instead of saving a single JS file every time, which is convenient for debugging and packaging
![[qt] qmap usage details](/img/ee/6e71a3dc5b90d2d1b7f7d3f6b56221.png)








