diff --git a/host/host.go b/host/host.go index ee9486369..b6be3a9a0 100644 --- a/host/host.go +++ b/host/host.go @@ -69,6 +69,12 @@ func EnableBootTimeCache(enable bool) { enableBootTimeCache = enable } +// RefreshBootTimeCache manually refreshes the cached BootTime value. +func RefreshBootTimeCache(ctx context.Context) error { + _, err := common.BootTimeWithContext(ctx, false) + return err +} + func Info() (*InfoStat, error) { return InfoWithContext(context.Background()) } diff --git a/process/process.go b/process/process.go index 1bb27abf8..6e1115f07 100644 --- a/process/process.go +++ b/process/process.go @@ -178,6 +178,12 @@ func EnableBootTimeCache(enable bool) { enableBootTimeCache = enable } +// RefreshBootTimeCache manually refreshes the cached BootTime value. +func RefreshBootTimeCache(ctx context.Context) error { + _, err := common.BootTimeWithContext(ctx, false) + return err +} + // Pids returns a slice of process ID list which are running now. func Pids() ([]int32, error) { return PidsWithContext(context.Background())