Refactor caching logic and add support for a new feature
Some checks failed
🚨 Test Code Base / 🧹 Lint (push) Failing after 5m24s
🚨 Test Code Base / 🔍 🐹 Go Tests (push) Failing after 5m45s
🏗️✨ Build Workflow / 🖥️ 🔨 Build (push) Failing after 6m14s

This commit is contained in:
2026-01-21 21:08:26 -05:00
parent 838051c880
commit d321d96fef
6 changed files with 128 additions and 94 deletions

View File

@@ -2,6 +2,7 @@ package http
import (
"net/http"
"os"
"github.com/labstack/echo/v4"
"github.com/siteworxpro/top-wallpaper/redis"
@@ -14,7 +15,10 @@ func Get(c echo.Context) error {
return c.String(http.StatusInternalServerError, "Internal Server Error: "+err.Error())
}
val, err := rc.Get(redis.CacheKey)
defer rc.Close()
nsfw := (c.QueryParam("nsfw") == "true" || c.QueryParam("nsfw") == "1") && os.Getenv("NSFW_MODE") == "true"
val, err := rc.Get(rc.GetCacheKey(nsfw))
if err != nil || val == "" {
return c.NoContent(http.StatusNoContent)