mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 08:46:56 +08:00
22 lines
336 B
Go
22 lines
336 B
Go
package timewheel
|
|
|
|
import "time"
|
|
|
|
var tw = New(time.Second, 3600)
|
|
|
|
func init() {
|
|
tw.Start()
|
|
}
|
|
|
|
func Delay(duration time.Duration, key string, job func()) {
|
|
tw.AddTimer(duration, key, job)
|
|
}
|
|
|
|
func At(at time.Time, key string, job func()) {
|
|
tw.AddTimer(at.Sub(time.Now()), key, job)
|
|
}
|
|
|
|
func Cancel(key string) {
|
|
tw.RemoveTimer(key)
|
|
}
|