Skip to content

Commit

Permalink
Log when a cache has finished loading
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Oct 30, 2020
1 parent 00ec6cf commit ba8d2f5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/cache/file_caches.go
Expand Up @@ -37,16 +37,18 @@ func NewFileCache(name, cacheSize, cacheFolder string, maxItems int, getReader R
}

go func() {
start := time.Now()
cache, err := newFSCache(fc.name, fc.cacheSize, fc.cacheFolder, fc.maxItems)
fc.mutex.Lock()
defer fc.mutex.Unlock()
if err == nil {
fc.cache = cache
fc.disabled = cache == nil
}
log.Info("Finished initializing cache", "cache", fc.name, "maxSize", fc.cacheSize, "elapsedTime", time.Since(start))
fc.ready = true
if fc.disabled {
log.Debug("Cache disabled", "cache", fc.name, "size", fc.cacheSize)
log.Debug("Cache DISABLED", "cache", fc.name, "size")
}
}()

Expand Down Expand Up @@ -182,7 +184,6 @@ func newFSCache(name, cacheSize, cacheFolder string, maxItems int) (fscache.Cach
return nil, nil
}

start := time.Now()
lru := fscache.NewLRUHaunter(maxItems, int64(size), consts.DefaultCacheCleanUpInterval)
h := fscache.NewLRUHaunterStrategy(lru)
cacheFolder = filepath.Join(conf.Server.DataFolder, cacheFolder)
Expand All @@ -195,10 +196,9 @@ func newFSCache(name, cacheSize, cacheFolder string, maxItems int) (fscache.Cach
fs, err = fscache.NewFs(cacheFolder, 0755)
}
if err != nil {
log.Error(fmt.Sprintf("Error initializing %s cache", name), err, "elapsedTime", time.Since(start))
log.Error(fmt.Sprintf("Error initializing %s cache", name), err)
return nil, err
}
log.Debug(fmt.Sprintf("%s cache initialized", name), "elapsedTime", time.Since(start))

return fscache.NewCacheWithHaunter(fs, h)
}

0 comments on commit ba8d2f5

Please sign in to comment.