MCPcopy Index your code
hub / github.com/upper/db / Clear

Method Clear

internal/cache/cache.go:129–140  ·  view source on GitHub ↗

Clear generates a new memory space, leaving the old memory unreferenced, so it can be claimed by the garbage collector.

()

Source from the content-addressed store, hash-verified

127// Clear generates a new memory space, leaving the old memory unreferenced, so
128// it can be claimed by the garbage collector.
129func (c *Cache) Clear() {
130 c.mu.Lock()
131 defer c.mu.Unlock()
132
133 for _, item := range c.items {
134 if p, ok := item.Value.(*cacheItem).value.(HasOnEvict); ok {
135 p.OnEvict()
136 }
137 }
138
139 c.init()
140}

Callers 3

ResetMethod · 0.80
CloseMethod · 0.80

Calls 2

initMethod · 0.95
OnEvictMethod · 0.65

Tested by 1