mirror of
https://github.com/safing/portbase
synced 2025-09-01 18:19:57 +00:00
Merge pull request #116 from safing/feature/database-cache-flushing
Add cache clearers
This commit is contained in:
commit
fa18d1ef4c
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