Skip to content

Commit

Permalink
Merge pull request #253 from systemli/Adjust-Response-Cache-TTLs
Browse files Browse the repository at this point in the history
⚡️ Adjust Response Cache TTLs
  • Loading branch information
0x46616c6b authored Oct 21, 2023
2 parents 872e690 + 8f067b4 commit 621acc2
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ func API(config config.Config, store storage.Storage, log *logrus.Logger) *gin.E
bridges: bridge.RegisterBridges(config, store),
}

// TOOD: Make this configurable via config file
cacheTtl := 30 * time.Second
inMemoryCache := cache.NewCache(5 * time.Minute)

gin.SetMode(gin.ReleaseMode)
Expand Down Expand Up @@ -114,9 +112,9 @@ func API(config config.Config, store storage.Storage, log *logrus.Logger) *gin.E
{
public.POST(`/admin/login`, authMiddleware.LoginHandler)

public.GET(`/init`, response_cache.CachePage(inMemoryCache, cacheTtl, handler.GetInit))
public.GET(`/timeline`, ticker.PrefetchTickerFromRequest(store), response_cache.CachePage(inMemoryCache, cacheTtl, handler.GetTimeline))
public.GET(`/feed`, ticker.PrefetchTickerFromRequest(store), response_cache.CachePage(inMemoryCache, cacheTtl, handler.GetFeed))
public.GET(`/init`, response_cache.CachePage(inMemoryCache, 5*time.Minute, handler.GetInit))
public.GET(`/timeline`, ticker.PrefetchTickerFromRequest(store), response_cache.CachePage(inMemoryCache, 10*time.Second, handler.GetTimeline))
public.GET(`/feed`, ticker.PrefetchTickerFromRequest(store), response_cache.CachePage(inMemoryCache, 5*time.Minute, handler.GetFeed))
}

r.GET(`/media/:fileName`, handler.GetMedia)
Expand Down

0 comments on commit 621acc2

Please sign in to comment.