mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-20 16:23:53 +01:00
23 lines
444 B
Go
23 lines
444 B
Go
package monitor
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/puzpuzpuz/xsync/v4"
|
|
)
|
|
|
|
var lastSeenMap = xsync.NewMap[string, time.Time](xsync.WithPresize(50), xsync.WithGrowOnly())
|
|
|
|
func SetLastSeen(service string, lastSeen time.Time) {
|
|
lastSeenMap.Store(service, lastSeen)
|
|
}
|
|
|
|
func UpdateLastSeen(service string) {
|
|
SetLastSeen(service, time.Now())
|
|
}
|
|
|
|
func GetLastSeen(service string) time.Time {
|
|
lastSeen, _ := lastSeenMap.Load(service)
|
|
return lastSeen
|
|
}
|