Add caching

This commit is contained in:
Ben Sarmiento
2023-10-22 13:29:41 +02:00
parent c789ebc96d
commit 6eccba394c
9 changed files with 74 additions and 55 deletions

View File

@@ -4,10 +4,12 @@ import (
"fmt"
"log"
"net/http"
"time"
"github.com/debridmediamanager.com/zurg/internal/config"
"github.com/debridmediamanager.com/zurg/internal/dav"
"github.com/debridmediamanager.com/zurg/internal/torrent"
"github.com/hashicorp/golang-lru/v2/expirable"
)
func main() {
@@ -18,8 +20,11 @@ func main() {
t := torrent.NewTorrentManager(c)
cache := expirable.NewLRU[string, string](1e4, nil, time.Hour)
mux := http.NewServeMux()
dav.Router(mux, c, t)
dav.Router(mux, c, t, cache)
addr := fmt.Sprintf(":%s", c.GetPort())
log.Printf("Starting server on %s\n", addr)
err := http.ListenAndServe(addr, mux)