allow usage of custom clear interval

This commit is contained in:
1e99 2024-10-30 16:57:52 +01:00
parent 5f2d2a408a
commit 154a739eff

15
main.go
View file

@ -6,6 +6,7 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"strconv"
"time" "time"
"git.1e99.eu/1e99/passed/middlewares" "git.1e99.eu/1e99/passed/middlewares"
@ -22,8 +23,20 @@ func run() error {
return err 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() { go func() {
ticker := time.Tick(20 * time.Second) ticker := time.Tick(time.Duration(clearInterval) * time.Second)
for { for {
<-ticker <-ticker