diff --git a/main.go b/main.go index d08e25f..4bd7136 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "log" "net/http" "os" + "strconv" "time" "git.1e99.eu/1e99/passed/middlewares" @@ -22,8 +23,20 @@ func run() error { return err } + clearIntervalString := os.Getenv("STORE_CLEAR_EXPIRED_INTERVAL") + if clearIntervalString == "" { + log.Printf("No STORE_CLEAR_EXPIRED_INTERVAL provided, defaulting to 30 seconds.") + clearIntervalString = "30" + } + + clearInterval, err := strconv.ParseInt(clearIntervalString, 10, 64) + if err != nil { + log.Printf("STORE_CLEAR_EXPIRED_INTERVAL is not a number.") + clearInterval = 30 + } + go func() { - ticker := time.Tick(20 * time.Second) + ticker := time.Tick(time.Duration(clearInterval) * time.Second) for { <-ticker