青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

那誰的技術博客

感興趣領域:高性能服務器編程,存儲,算法,Linux內核
隨筆 - 210, 文章 - 0, 評論 - 1183, 引用 - 0
數據加載中……

The design and implementation of CommonCache Library(base on version 0.6)


1. Overview

a) the functions of a cache
cache the most frequently visited data in the memory, so:
1) if the the data get losed is not a big matter,it means that you should not store data
in cache only, offen, cache is between the DB server and application,hence reduce visiting DB times
 and speed up application.
2) since the memory is not quite big, so the eliminating algorithm such LRU must to be used.
3) must support key-value-like API such as find/erase/set and so forth.

b) ccache feature (version 0.6):
1) using mmap to cache data in file, so it can be used in multi-thead and multi-process application.
2) support unfix size key node
3) support hash-rbtree and hash-list structure
4) use LRU algorithm to eliminate nodes when it is running out of its memory size
5) fast, 100W/read operation on fix-size key node in no more than 0.5 second

c) what is the difference between ccache and memcached?
ccache is a static library, memcached is a cache sever, so users who use ccache must
design the protocols between clients and server, and write the server application themself.

2. implementation
a) the cache file structure


b) the hashitem array detail   
the hashitem array is used to find the node base on the node key.Every nodes in a
same hashitem has a same hash num.All the nodes in the same hashitem are strutured
in list or rbtree:


when compiling the ccache, define the macro CCACHE_USE_RBTREE to specily using rbtree,
else macro CCACHE_USE_LIST using list. The structrue ccache_node_t has following fields
about this:

typedef struct ccache_node_t
{
        
/* 
          
         
*/

#ifdef CCACHE_USE_LIST
    
struct ccache_node_t *next, *prev;
#elif defined CCACHE_USE_RBTREE    
    ccache_color_t color;
    
struct ccache_node_t *parent, *left, *right;
#endif

        
/* 
          
         
*/

}
ccache_node_t;

the hashitem array size is defined in the configure file when open the cache.

c) the freearea array detail   
ccache use slab-like algorithm to allocate node memory.In the configure file, there is an
item called "alignsize", this value specify the align size between different freearea,
assume the alignsize is 8 bytes:

all the nodes in the same freearea has the same size, when allocating a node(ccache_memory.c/ccache_allocate):
1) allign the node size with the alignsize value, then find the fit
freearea(ccache_memory.c/ccache_get_freeareaid) and return the freeareaid
2) if the data zone has enough memory for the node, change the cache->start_free and cache->freesize
and return the node pointer
3) else, erase the  cache->freearea[freeareaid]->lrulast node, use this node memory
for this allocation.
4) every time a node allocated, place it in the freearea's tail(freearea->lrulast = node),
when the node has been visited, it move on one step in the freearea list.So, the more a node has been
visited, the closer it moves to the freearea head(freearea->lrufirst).Hence, the freearea lrulast
node is the less frequently visited node in the freearea(although not so accurate:).

the ccache_node_t structure has following fields about LRU:

typedef struct ccache_node_t
{
    
/*
       .
    
*/
       
    
struct ccache_node_t *lrunext, *lruprev;

    
/*
       .
    
*/
       
}
ccache_node_t;

 

 

posted on 2009-10-22 21:11 那誰 閱讀(4122) 評論(1)  編輯 收藏 引用 所屬分類: ccache

評論

# re: The design and implementation of CommonCache Library(base on version 0.6)  回復  更多評論   

開源,大力支持??!
中國缺少這樣的東西
2010-03-10 19:37 | jesse
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲一区久久久| 欧美激情在线有限公司| 一本久道久久综合狠狠爱| 欧美国产日韩二区| 亚洲精品在线免费| 99精品欧美一区二区三区| 欧美亚洲成人精品| 久久久久久久久岛国免费| 久久久久免费视频| 99ri日韩精品视频| 亚洲先锋成人| 亚洲免费av网站| 性久久久久久久久| 99re8这里有精品热视频免费| 日韩视频不卡| 国产亚洲精品aa午夜观看| 久久国产天堂福利天堂| 久久精品毛片| 一区二区三区高清视频在线观看| 在线一区二区日韩| 精品电影一区| 亚洲欧洲在线免费| 国产日本欧美视频| 亚洲高清123| 国产日韩在线不卡| 亚洲激情在线观看| 韩国成人精品a∨在线观看| 亚洲激情欧美激情| 国产亚洲精品久| 亚洲麻豆一区| 国产精品亚洲精品| 亚洲最新视频在线| 欧美成人免费网站| 国产精品久久久久一区二区三区共| 久久精品国产精品| 欧美日韩视频免费播放| 久久综合激情| 国产精品欧美一区喷水 | 久久综合网络一区二区| 亚洲一区二区免费| 免费亚洲电影| 狂野欧美激情性xxxx| 国产精品日韩电影| 亚洲精品久久久蜜桃| 亚洲电影下载| 欧美自拍偷拍午夜视频| 午夜精品婷婷| 欧美激情精品久久久久久蜜臀| 国产综合av| 久久都是精品| 国产精品jizz在线观看美国 | 亚洲激情视频网| 永久域名在线精品| 亚洲乱码精品一二三四区日韩在线| 午夜宅男欧美| 久久国产精品电影| 国产精品色一区二区三区| 99精品视频免费在线观看| 亚洲精品久久久久久下一站| 久久青草福利网站| 蜜乳av另类精品一区二区| 国产自产女人91一区在线观看| 亚洲欧美国内爽妇网| 欧美一区二区在线免费观看| 国产精品久久久久99| 一区二区三区三区在线| 另类激情亚洲| 国产精品亚洲视频| 亚洲一区在线播放| 亚洲欧美视频一区二区三区| 国产精品成人aaaaa网站| 亚洲视频二区| 久久精品理论片| 国内久久婷婷综合| 久久久蜜桃精品| 欧美成人免费大片| 亚洲精品国产精品乱码不99按摩| 欧美国产日韩精品| 一区二区三区精品视频| 亚洲欧美日韩在线观看a三区| 国产精品日本欧美一区二区三区| 亚洲欧美一区二区精品久久久| 久久久福利视频| 亚洲国产精品久久久久秋霞不卡 | 久久久久久网址| 国内外成人免费视频| 亚洲视频在线视频| 一区二区三区 在线观看视频| 欧美成人精品福利| 亚洲精品视频免费观看| 欧美欧美天天天天操| 国产精品99久久99久久久二8| 久久精品官网| 亚洲欧洲日产国产综合网| 欧美日韩高清免费| 午夜老司机精品| 亚洲国产精品毛片| 午夜精品久久久久久久99热浪潮| 狠狠色伊人亚洲综合成人| 欧美日本簧片| 欧美在线视频日韩| 亚洲精品欧美极品| 久久欧美肥婆一二区| 这里只有精品电影| 在线观看视频亚洲| 国产精品嫩草久久久久| 猛干欧美女孩| 亚洲欧美日韩网| 久久久亚洲精品一区二区三区 | 国产一区二区三区不卡在线观看| 久久精品九九| 一区二区三区日韩在线观看| 欧美顶级艳妇交换群宴| 销魂美女一区二区三区视频在线| 亚洲国产精品成人| 国产日韩精品久久久| 欧美精品一区三区| 久久精品五月婷婷| 亚洲伊人一本大道中文字幕| 亚洲高清免费| 麻豆免费精品视频| 欧美一区二区视频观看视频| 亚洲精品一区二| 在线成人亚洲| 国产综合欧美在线看| 国产精品免费电影| 欧美日韩综合不卡| 欧美激情一级片一区二区| 久久免费高清| 久久久噜噜噜久久中文字免| 欧美一区二区视频免费观看 | 国产日韩一区二区三区在线播放 | 免费试看一区| 久久麻豆一区二区| 欧美中日韩免费视频| 香蕉久久国产| 亚洲女ⅴideoshd黑人| 一本一本大道香蕉久在线精品| 亚洲激情欧美激情| 亚洲三级色网| 亚洲欧洲一区| 日韩午夜在线视频| 日韩一级精品| 亚洲少妇诱惑| 亚洲一区二区精品在线| 亚洲免费伊人电影在线观看av| 亚洲一区在线观看免费观看电影高清 | 国一区二区在线观看| 加勒比av一区二区| 亚洲第一精品夜夜躁人人躁| 黄色成人免费网站| 亚洲二区免费| 日韩亚洲欧美在线观看| 一区二区三区国产精华| 亚洲免费在线观看视频| 欧美一区二区免费| 久久久久久电影| 欧美第一黄色网| 国产日韩在线一区二区三区| 国产一区二区三区视频在线观看| 国产日韩一区在线| 亚洲欧洲精品一区二区三区不卡| 99精品免费网| 欧美一区2区三区4区公司二百 | 一区二区三区免费看| 亚洲欧美久久久| 久久亚洲精品一区| 亚洲国产1区| 亚洲网站视频| 久久亚洲一区| 欧美天堂亚洲电影院在线观看| 国产美女精品视频免费观看| 永久域名在线精品| 一道本一区二区| 久久久久一区二区三区| 欧美黄色小视频| 亚洲一区二区三区视频| 久久裸体视频| 国产精品久久久久久模特| 好吊妞**欧美| 亚洲在线中文字幕| 欧美大片在线看| 亚洲综合日韩| 欧美高清视频在线| 国产一区二区三区在线观看精品| 亚洲精品欧美极品| 久久色在线观看| 一区二区三区 在线观看视| 久久视频在线免费观看| 国产精品亚洲综合一区在线观看| 亚洲国产一区二区三区青草影视| 欧美影片第一页| 亚洲每日更新| 欧美91大片| 精品成人在线视频| 久久国产福利| 这里是久久伊人| 欧美激情视频给我| 亚洲第一精品夜夜躁人人爽| 久久久久一本一区二区青青蜜月|