item是Memcached中抽象實際資料的結構,我們分析下item的一些特性,便于後續Memcached的其他特性分析。
typedef struct _stritem {
struct _stritem *next;//item在slab中存儲時,是以雙連結清單的形式存儲的,next即後向指針
struct _stritem *prev;//prev為前向指針
struct _stritem *h_next;//Hash桶中元素的連結指針
rel_time_t time; //最近通路時間
rel_time_t exptime;//過期時間
int nbytes;//資料大小
unsigned short refcount;//引用次數
uint8_t nsuffix; //不清楚什麼意思?
uint8_t it_flags; //不清楚什麼意思?
uint8_t slabs_clsid;//标記item屬于哪個slabclass下
uint8_t nkey; //key的長度
union {
uint64_t cas;
char end;
} data[];//真實的資料資訊
} item;
其結構圖如下所示:

即Item由兩部分組成,item的屬性資訊和item的資料部分,屬性資訊解釋如上,資料部分包括cas,key和真實的value資訊,item在記憶體中的存儲形式如下:
這個圖畫出了部分結構,還有Hash表的結構沒有畫出。
這裡大概介紹了item的一些資訊,後面我們會分析item插入Hash表等資訊。
注:本篇部落格的圖檔摘自:http://kenby.iteye.com/blog/1423989
http://www.nosqlnotes.net/archives/222