From 154a739eff3f1ddd37e6cb2b1fc3722db2750692 Mon Sep 17 00:00:00 2001 From: 1e99 Date: Wed, 30 Oct 2024 16:57:52 +0100 Subject: [PATCH] allow usage of custom clear interval --- main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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