allow usage of custom clear interval
This commit is contained in:
parent
5f2d2a408a
commit
154a739eff
1 changed files with 14 additions and 1 deletions
15
main.go
15
main.go
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue