- 愿意消耗一些内存空间来提升速度
- 预料到某些键会被多次查询
- 缓存中存放的数据总量不会超出内存容量
Caffeine提供三类驱逐策略:
- 基于大小(size-based)
- 基于时间(time-based)
- 基于引用(reference-based)
who is the author of ConcurrentLinkedHashMap on which Guava cache is based.
guava out
- guava sync operation
- non-blocking without aware
Caffeine uses both a Least Recently Used (LRU) eviction policy and a frequency-based admission policy relying on CountMin sketch. It has a better hit rate than LRU for many workloads.
使用ring buffers的方式,The ring buffer approach avoids allocation, is bounded (lossy), and cheaper to operate against.
Caffeine uses ring buffers to record & replay events, whereas Guava uses ConcurrentLinkedQueue
.