Documentation
¶
Overview ¶
Package cache provides a TTL caching wrapper around a gpu.Collector.
The wrapper takes a single consistent snapshot of all devices per refresh: the first read after expiry calls the inner DeviceCount() once and then Device(0..n-1) once each, stores the resulting []gpu.Device with a fetch timestamp, and serves every read within the TTL window from that snapshot without touching the inner collector. Errors during a refresh are never cached — they propagate to the caller and leave the cache invalid so the next read retries. Init, Shutdown and Backend pass straight through.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cached ¶
type Cached struct {
// contains filtered or unexported fields
}
Cached wraps a gpu.Collector and serves DeviceCount/Device from a snapshot refreshed at most once per ttl. All snapshot state is mutex-guarded.
func (*Cached) Device ¶
Device returns a copy pointer to the device at index i from the current snapshot, refreshing first if the snapshot is missing or expired. It returns an error if i is out of range.
func (*Cached) DeviceCount ¶
DeviceCount returns the number of devices in the current snapshot, refreshing first if the snapshot is missing or expired.