您的当前位置:首页 >数据库 >Redis内部数据结构SDS详解 正文

Redis内部数据结构SDS详解

时间:2025-11-05 05:15:03 来源:网络整理编辑:数据库

核心提示

复制//定义五种不同的结构体,sdshdr5,sdshdr8,sdshdr16,sdshdr32,sdshdr64 struct__attribute__((__packed__

Redis内部数据结构SDS详解
复制//定义五种不同的部数结构体,源码库sdshdr5,据结sdshdr8, sdshdr16,sdshdr32,sdshdr64  struct __attribute__ ((__packed__)) sdshdr5 {      unsigned char flags; // 8位的网站模板标记      char buf[];//实际数据的亿华云指针 };  struct __attribute__ ((__packed__)) sdshdr8 {      uint8_t len; /* 已使用长度 */      uint8_t alloc; /* 总长度*/      unsigned char flags;      char buf[]; };  struct __attribute__ ((__packed__)) sdshdr16 {      uint16_t len;      uint16_t alloc;      unsigned char flags;      char buf[]; };  struct __attribute__ ((__packed__)) sdshdr32 {      uint32_t len;      uint32_t alloc;      unsigned char flags;      char buf[]; };  struct __attribute__ ((__packed__)) sdshdr64 {      uint64_t len;      uint64_t alloc;      unsigned char flags;      char buf[]; };  1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.