CCache is an LRU Cache, written in Go, focused on supporting high concurrency.
Lock contention on the list is reduced by:
- Introducing a window which limits the frequency that an item can get promoted
- Using a buffered channel to queue promotions for a single worker
- Garbage collecting within the same thread as the worker
如何实现
1 | type Cache struct { |
数据存放在bucket里
1 | type bucket struct { |
CCache’s LayeredCache
stores and retrieves values by both a primary and secondary key. Deletion can happen against either the primary and secondary key, or the primary key only (removing all values that share the same primary key).
双层key?