NewCache returns a newly initialize cache by size. The cache size will be set to 512KB at minimum. If the size is set relatively large, you should call `debug.SetGCPercent()`, set it to a much smaller value to limit the memory consumption and GC pause time.
(size int)
| 34 | // `debug.SetGCPercent()`, set it to a much smaller value |
| 35 | // to limit the memory consumption and GC pause time. |
| 36 | func NewCache(size int) (cache *Cache) { |
| 37 | return NewCacheCustomTimer(size, defaultTimer{}) |
| 38 | } |
| 39 | |
| 40 | // NewCacheCustomTimer returns new cache with custom timer. |
| 41 | func NewCacheCustomTimer(size int, timer Timer) (cache *Cache) { |
searching dependent graphs…