NewCacheCustomTimer returns new cache with custom timer.
(size int, timer Timer)
| 39 | |
| 40 | // NewCacheCustomTimer returns new cache with custom timer. |
| 41 | func 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, |
searching dependent graphs…