MCPcopy
hub / github.com/coocood/freecache / NewCache

Function NewCache

cache.go:36–38  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

34// `debug.SetGCPercent()`, set it to a much smaller value
35// to limit the memory consumption and GC pause time.
36func NewCache(size int) (cache *Cache) {
37 return NewCacheCustomTimer(size, defaultTimer{})
38}
39
40// NewCacheCustomTimer returns new cache with custom timer.
41func NewCacheCustomTimer(size int, timer Timer) (cache *Cache) {

Callers 15

NewServerFunction · 0.92
TestFreeCacheFunction · 0.85
TestOverwriteFunction · 0.85
TestGetOrSetFunction · 0.85
TestGetWithExpirationFunction · 0.85
TestPeekWithExpirationFunction · 0.85
TestMultiGetFunction · 0.85
TestExpireFunction · 0.85
TestTouchFunction · 0.85

Calls 1

NewCacheCustomTimerFunction · 0.85

Tested by 15

TestFreeCacheFunction · 0.68
TestOverwriteFunction · 0.68
TestGetOrSetFunction · 0.68
TestGetWithExpirationFunction · 0.68
TestPeekWithExpirationFunction · 0.68
TestMultiGetFunction · 0.68
TestExpireFunction · 0.68
TestTouchFunction · 0.68
TestLargeEntryFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…