mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-25 13:16:40 +00:00
adbc87700a
Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
21 lines
481 B
Go
21 lines
481 B
Go
package ttl
|
|
|
|
import (
|
|
"time"
|
|
|
|
"codeberg.org/gruf/go-sched"
|
|
)
|
|
|
|
// scheduler is the global cache runtime
|
|
// scheduler for handling cache evictions.
|
|
var scheduler sched.Scheduler
|
|
|
|
// schedule will given sweep routine to the global scheduler, and start global scheduler.
|
|
func schedule(sweep func(time.Time), freq time.Duration) func() {
|
|
if !scheduler.Running() {
|
|
// ensure sched running
|
|
_ = scheduler.Start(nil)
|
|
}
|
|
return scheduler.Schedule(sched.NewJob(sweep).Every(freq))
|
|
}
|