30 lines
450 B
Go
30 lines
450 B
Go
package ICCC
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Setup and starts the cache timer.
|
|
func initCacheTimer() {
|
|
startCacheTimerLock.Lock()
|
|
defer startCacheTimerLock.Unlock()
|
|
|
|
if cacheTimerRunning {
|
|
return
|
|
} else {
|
|
cacheTimerRunning = true
|
|
}
|
|
|
|
// Start another thread with the timer-logic:
|
|
go func() {
|
|
// Endless loop:
|
|
for {
|
|
// Execute the logic:
|
|
cacheTimerLogic()
|
|
|
|
// Wait five minutes:
|
|
time.Sleep(time.Duration(5) * time.Minute)
|
|
}
|
|
}()
|
|
}
|