Merge pull request #11 from colin-axner/colin/memo-reset

Add (forceful) Reset function to memo
This commit is contained in:
Matt Baer
2021-03-06 16:51:49 -05:00
committed by GitHub
+10
View File
@@ -67,3 +67,13 @@ 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 without checking if the cache
// duration has elapsed.
func (memo *Memo) Reset() {
defer memo.mu.Unlock()
memo.mu.Lock()
memo.cache = nil
memo.lastCache = time.Now()
}