feat: cache download status number

This commit is contained in:
Simon Ding
2024-12-11 20:04:37 +08:00
parent 7c05acd1cf
commit 1020190c01
2 changed files with 28 additions and 16 deletions

View File

@@ -7,9 +7,11 @@ import (
"net/url"
"polaris/db"
"polaris/log"
"polaris/pkg/cache"
"polaris/pkg/tmdb"
"polaris/server/core"
"polaris/ui"
"time"
ginzap "github.com/gin-contrib/zap"
@@ -22,20 +24,24 @@ import (
func NewServer(db *db.Client) *Server {
r := gin.Default()
s := &Server{
r: r,
db: db,
language: db.GetLanguage(),
r: r,
db: db,
language: db.GetLanguage(),
monitorNumCache: cache.NewCache[int, int](10 * time.Minute),
downloadNumCache: cache.NewCache[int, int](10 * time.Minute),
}
s.core = core.NewClient(db, s.language)
return s
}
type Server struct {
r *gin.Engine
db *db.Client
core *core.Client
language string
jwtSerect string
r *gin.Engine
db *db.Client
core *core.Client
language string
jwtSerect string
monitorNumCache *cache.Cache[int, int]
downloadNumCache *cache.Cache[int, int]
}
func (s *Server) Serve() error {