Commit e90d3868 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Add TimedCache.DropAll and CachingFileSystem.DropCache

parent 5af34567
......@@ -96,6 +96,12 @@ func NewCachingFileSystem(fs fuse.FileSystem, ttlNs int64) *CachingFileSystem {
return c
}
func (me *CachingFileSystem) DropCache() {
for _, c := range []*TimedCache{me.attributes, me.dirs, me.links, me.xattr} {
c.DropAll()
}
}
func (me *CachingFileSystem) GetAttr(name string) (*os.FileInfo, fuse.Status) {
r := me.attributes.Get(name).(*attrResponse)
return r.FileInfo, r.Status
......
......@@ -97,3 +97,9 @@ func (me *TimedCache) RecurringPurge() {
me.PurgeTimer = time.AfterFunc(5*me.ttlNs,
func() { me.RecurringPurge() })
}
func (me *TimedCache) DropAll() {
me.cacheMapMutex.Lock()
defer me.cacheMapMutex.Unlock()
me.cacheMap = make(map[string]*cacheEntry, len(me.cacheMap))
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment