Add Reset func to memo

Add a new function Reset to memo to forcibly reset the cache
This commit is contained in:
Colin Axner
2020-11-23 15:36:27 +01:00
parent aacd7d3d0c
commit cee889bd58
+9
View File
@@ -67,3 +67,12 @@ func (memo *Memo) Get() (value interface{}, err error) {
} }
return memo.cache.res.value, memo.cache.res.err return memo.cache.res.value, memo.cache.res.err
} }
// Reset forcibly resets the cache to nil.
func (memo *Memo) Reset() {
defer memo.mu.Unlock()
memo.mu.Lock()
memo.cache = nil
memo.lastCache = time.Now()
}