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

Function NewCacheCustomTimer

cache.go:41–53  ·  view source on GitHub ↗

NewCacheCustomTimer returns new cache with custom timer.

(size int, timer Timer)

Source from the content-addressed store, hash-verified

39
40// NewCacheCustomTimer returns new cache with custom timer.
41func NewCacheCustomTimer(size int, timer Timer) (cache *Cache) {
42 if size < minBufSize {
43 size = minBufSize
44 }
45 if timer == nil {
46 timer = defaultTimer{}
47 }
48 cache = new(Cache)
49 for i := 0; i < segmentCount; i++ {
50 cache.segments[i] = newSegment(size/segmentCount, i, timer)
51 }
52 return
53}
54
55// Set sets a key, value and expiration for a cache entry and stores it in the cache.
56// If the key is larger than 65535 or value is larger than 1/1024 of the cache size,

Callers 6

NewCacheFunction · 0.85
TestPeekWithExpirationFunction · 0.85
testTTLWithNoExpireKeyFunction · 0.85
testTTLWithExpiredKeyFunction · 0.85
testTTLWithNotFoundKeyFunction · 0.85

Calls 1

newSegmentFunction · 0.85

Tested by 5

TestPeekWithExpirationFunction · 0.68
testTTLWithNoExpireKeyFunction · 0.68
testTTLWithExpiredKeyFunction · 0.68
testTTLWithNotFoundKeyFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…