refactor: move cache constructor

This commit is contained in:
Deluan
2020-02-21 09:36:29 -05:00
parent 13a046a679
commit 1322bb3bf3
2 changed files with 13 additions and 17 deletions
-17
View File
@@ -1,14 +1,8 @@
package engine
import (
"path/filepath"
"time"
"github.com/deluan/navidrome/conf"
"github.com/deluan/navidrome/consts"
"github.com/deluan/navidrome/engine/ffmpeg"
"github.com/google/wire"
"gopkg.in/djherbis/fscache.v0"
)
var Set = wire.NewSet(
@@ -25,14 +19,3 @@ var Set = wire.NewSet(
ffmpeg.New,
NewTranscodingCache,
)
func NewTranscodingCache() (fscache.Cache, error) {
lru := fscache.NewLRUHaunter(0, conf.Server.MaxTranscodingCacheSize, 10*time.Minute)
h := fscache.NewLRUHaunterStrategy(lru)
cacheFolder := filepath.Join(conf.Server.DataFolder, consts.CacheDir)
fs, err := fscache.NewFs(cacheFolder, 0755)
if err != nil {
return nil, err
}
return fscache.NewCacheWithHaunter(fs, h)
}