freecache原理

https://github.com/coocood/freecache coocood/freecache

https://github.com/allegro/bigcache allegro/bigcache

簡單來說:shards map + map[uint]uint + []byte + free link = BigCache
定義 shards cache,避免鎖粒度過大
map 裏只存放 uint 避免指針
實現一個 queue 結構(實際是[]byte,通過 uint 下標追加分配)
採用 free 鏈機制,刪除保留空洞最後一起回收

https://blog.csdn.net/chizhenlian/article/details/108435024 深入理解Freecache

https://mp.weixin.qq.com/s/SWfPV6tUC5olZgIdVabd3A Go 內存池/對象池技術介紹

簡單附上一個草圖,用於個人記憶;實現細節,可以結合草圖閱讀源碼。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章