当前位置:网站首页>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 */ };
边栏推荐
- [wechat applet] how did the conditional rendering list render work?
- Simple custom MVC
- 华为面试题: 分糖果
- 一篇文章带你入门vim
- 快速排序、聚簇索引、尋找數據中第k大的值
- X书6.97版本shield-unidbg调用方式
- Regular full match: the password consists of more than 8 digits, upper and lower case letters, and special characters
- JS 字母和数字的相互转换
- Deep learning: implementation skills of deep neural network
- [QT] QMap使用详解
猜你喜欢
Mathematical solution of Joseph Ring
1148_ Makefile learning_ Targets, variables, and wildcards in makefile
[QT] QMap使用详解
X书6.97版本shield-unidbg调用方式
Compile a DLL without import table
如何实现远程协同办公,收好这份攻略!
Prompt learning a blood case caused by a space
Gulang bilibilibili Live Screen Jackie
X Book 6.97 shield unidbg calling method
F1C100S自制开发板调试过程
随机推荐
Mysql性能优化(6):读写分离
4-4 beauty ranking (10 points)
Prompt learning a blood case caused by a space
F1c100s self made development board debugging process
C#【高级篇】 C# 接口(Interface)
TiDB 6.0:讓 TSO 更高效丨TiDB Book Rush
Linked list: insert a node in the head
[QT] QMap使用详解
问题记录:fel_lib.c:26:10: fatal error: libusb.h: 没有那个文件或目录
Local, locallow and roaming in the appdata folder
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
Use of custom MVC
DC/DC变换器轻载时三种工作模式的原理及优缺点
1150_ Makefile learning_ Duplicate name target processing in makefile
[live broadcast notes 0629] Concurrent Programming II: lock
正则全匹配:密码由8位以上数字,大小写字母,特殊字符组成
MySQL + JSON = King fried
Formal and actual parameters, value passing and address passing
设备驱动程序的原理