mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-27 14:16:39 +00:00
18 lines
473 B
Go
18 lines
473 B
Go
|
package cache
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"codeberg.org/gruf/go-sched"
|
||
|
)
|
||
|
|
||
|
// scheduler is the global cache runtime scheduler
|
||
|
// for handling regular cache evictions.
|
||
|
var scheduler = sched.NewScheduler(5)
|
||
|
|
||
|
// schedule will given sweep routine to the global scheduler, and start global scheduler.
|
||
|
func schedule(sweep func(time.Time), freq time.Duration) func() {
|
||
|
go scheduler.Start() // does nothing if already running
|
||
|
return scheduler.Schedule(sched.NewJob(sweep).Every(freq))
|
||
|
}
|