more efficient caching

This commit is contained in:
Ben Sarmiento
2023-10-22 14:25:28 +02:00
parent 6eccba394c
commit 16d6bf4f81
3 changed files with 27 additions and 23 deletions

View File

@@ -13,19 +13,19 @@ import (
)
func main() {
c, cErr := config.LoadZurgConfig("./config.yml")
if cErr != nil {
log.Panicf("Config failed to load: %v", cErr)
config, configErr := config.LoadZurgConfig("./config.yml")
if configErr != nil {
log.Panicf("Config failed to load: %v", configErr)
}
t := torrent.NewTorrentManager(c)
cache := expirable.NewLRU[string, string](1e4, nil, time.Hour)
mux := http.NewServeMux()
dav.Router(mux, c, t, cache)
t := torrent.NewTorrentManager(config, cache)
addr := fmt.Sprintf(":%s", c.GetPort())
mux := http.NewServeMux()
dav.Router(mux, config, t, cache)
addr := fmt.Sprintf(":%s", config.GetPort())
log.Printf("Starting server on %s\n", addr)
err := http.ListenAndServe(addr, mux)
if err != nil {