mirror of
https://github.com/safing/portbase
synced 2025-09-01 01:59:48 +00:00
Add cache clearers
This commit is contained in:
parent
997407cc71
commit
99df25b589
1 changed files with 21 additions and 0 deletions
|
@ -61,6 +61,27 @@ func (i *Interface) DelayedCacheWriter(ctx context.Context) error {
|
|||
}
|
||||
}
|
||||
|
||||
// ClearCache clears the read cache.
|
||||
func (i *Interface) ClearCache() {
|
||||
// Check if cache is in use.
|
||||
if i.cache == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Clear all cache entries.
|
||||
i.cache.Purge()
|
||||
}
|
||||
|
||||
// FlushCache writes (and thus clears) the write cache.
|
||||
func (i *Interface) FlushCache() {
|
||||
// Check if write cache is in use.
|
||||
if i.options.DelayCachedWrites != "" {
|
||||
return
|
||||
}
|
||||
|
||||
i.flushWriteCache(0)
|
||||
}
|
||||
|
||||
func (i *Interface) flushWriteCache(percentThreshold int) {
|
||||
i.writeCacheLock.Lock()
|
||||
defer i.writeCacheLock.Unlock()
|
||||
|
|
Loading…
Add table
Reference in a new issue