diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -63,21 +63,12 @@ func init() { logger.Debug("Logging configured", "log level", logLevel) slingshotURL := os.Getenv("SLINGSHOT_URL") - ttlMin := os.Getenv("TTL_MIN") + postExpiryMinutes := parseTTLMinutes("POST_TTL_MIN", 4320) + profileExpiryMinutes := parseTTLMinutes("PROFILE_TTL_MIN", 10080) - var expiryMinutes int - if ttlMin != "" { - var err error - expiryMinutes, err = strconv.Atoi(ttlMin) - if err != nil { - panic(err) - } - } else { - expiryMinutes = 15 - } valkeyAddr := os.Getenv("VALKEY_ADDR") valkeyPassword := os.Getenv("VALKEY_PASSWORD") - postCache, err := fetchers.NewCache(valkeyAddr, valkeyPassword, expiryMinutes) + postCache, err := fetchers.NewCache(valkeyAddr, valkeyPassword, postExpiryMinutes, profileExpiryMinutes) if err != nil { logger.Error("failed to connect to valkey", "error", err) panic(err) @@ -103,6 +94,19 @@ func init() { } } +func parseTTLMinutes(envVar string, defaultMinutes int) int { + raw := os.Getenv(envVar) + if raw == "" { + return defaultMinutes + } + + minutes, err := strconv.Atoi(raw) + if err != nil { + panic(err) + } + return minutes +} + func loginHandler(w http.ResponseWriter, r *http.Request) { handle := r.URL.Query().Get("handle") if handle == "" { |
