Skip to content

Commit

Permalink
fix: revert cached endpoints
Browse files Browse the repository at this point in the history
- this breaks a lot of stuff
  • Loading branch information
5rahim committed May 25, 2024
1 parent 26700ea commit ddb3b20
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
27 changes: 13 additions & 14 deletions internal/handlers/anime_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package handlers
import (
"errors"
"github.com/seanime-app/seanime/internal/library/anime"
"github.com/seanime-app/seanime/internal/util"
"github.com/seanime-app/seanime/internal/util/limiter"
"github.com/seanime-app/seanime/internal/util/result"
)

var libraryCollectionMap = result.NewResultMap[string, *anime.LibraryCollection]()
//var libraryCollectionMap = result.NewResultMap[string, *anime.LibraryCollection]()

// HandleGetLibraryCollection
//
Expand All @@ -28,11 +26,12 @@ func HandleGetLibraryCollection(c *RouteCtx) error {
return c.RespondWithError(err)
}

ret, ok := libraryCollectionMap.Get(util.GetMemAddrStr(anilistCollection))
if ok {
c.App.Logger.Debug().Msg("api: Library collection cache HIT")
return c.RespondWithData(ret)
}
// DEVNOTE: Bad
//ret, ok := libraryCollectionMap.Get(util.GetMemAddrStr(anilistCollection))
//if ok {
// c.App.Logger.Debug().Msg("api: Library collection cache HIT")
// return c.RespondWithData(ret)
//}

lfs, _, err := c.App.Database.GetLocalFiles()
if err != nil {
Expand All @@ -50,12 +49,12 @@ func HandleGetLibraryCollection(c *RouteCtx) error {
return c.RespondWithError(err)
}

go func() {
if libraryCollection != nil {
libraryCollectionMap.Clear()
libraryCollectionMap.Set(util.GetMemAddrStr(anilistCollection), libraryCollection)
}
}()
//go func() {
// if libraryCollection != nil {
// libraryCollectionMap.Clear()
// libraryCollectionMap.Set(util.GetMemAddrStr(anilistCollection), libraryCollection)
// }
//}()

return c.RespondWithData(libraryCollection)
}
Expand Down
26 changes: 13 additions & 13 deletions internal/handlers/anime_entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/seanime-app/seanime/internal/library/anime"
"github.com/seanime-app/seanime/internal/library/scanner"
"github.com/seanime-app/seanime/internal/library/summary"
"github.com/seanime-app/seanime/internal/util"
"github.com/seanime-app/seanime/internal/util/limiter"
"github.com/seanime-app/seanime/internal/util/result"
"github.com/sourcegraph/conc/pool"
Expand Down Expand Up @@ -452,7 +451,7 @@ func HandleAnimeEntryManualMatch(c *RouteCtx) error {

//----------------------------------------------------------------------------------------------------------------------

var missingEpisodesMap = result.NewResultMap[string, *anime.MissingEpisodes]()
//var missingEpisodesMap = result.NewResultMap[string, *anime.MissingEpisodes]()

// HandleGetMissingEpisodes
//
Expand All @@ -471,11 +470,12 @@ func HandleGetMissingEpisodes(c *RouteCtx) error {
return c.RespondWithError(err)
}

ret, ok := missingEpisodesMap.Get(util.GetMemAddrStr(anilistCollection))
if ok {
c.App.Logger.Info().Msg("api: Library collection cache HIT")
return c.RespondWithData(ret)
}
// DEVNOTE: Bad
//ret, ok := missingEpisodesMap.Get(util.GetMemAddrStr(anilistCollection))
//if ok {
// c.App.Logger.Info().Msg("api: Library collection cache HIT")
// return c.RespondWithData(ret)
//}

lfs, _, err := c.App.Database.GetLocalFiles()
if err != nil {
Expand All @@ -493,12 +493,12 @@ func HandleGetMissingEpisodes(c *RouteCtx) error {
MetadataProvider: c.App.MetadataProvider,
})

go func() {
if missingEps != nil {
missingEpisodesMap.Clear()
missingEpisodesMap.Set(util.GetMemAddrStr(anilistCollection), missingEps)
}
}()
//go func() {
// if missingEps != nil {
// missingEpisodesMap.Clear()
// missingEpisodesMap.Set(util.GetMemAddrStr(anilistCollection), missingEps)
// }
//}()

return c.RespondWithData(missingEps)

Expand Down

0 comments on commit ddb3b20

Please sign in to comment.