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 内存池/对象池技术介绍

简单附上一个草图,用于个人记忆;实现细节,可以结合草图阅读源码。(字迹有点丑,缩小了,见谅)

posted @ 2021-08-28 17:57  Michael-Xu  阅读(129)  评论(0编辑  收藏  举报