diff --git a/provider/azure/cache.go b/provider/azure/cache.go index 5f3f0295f..9cde58fe2 100644 --- a/provider/azure/cache.go +++ b/provider/azure/cache.go @@ -27,7 +27,8 @@ type zonesCache[T any] struct { zones []T } -// Reset method to reset the zones and update the age +// Reset method to reset the zones and update the age. This will be used to update the cache +// after making a new API call to get the zones. func (z *zonesCache[T]) Reset(zones []T) { if z.duration > time.Duration(0) { z.age = time.Now() @@ -35,12 +36,15 @@ func (z *zonesCache[T]) Reset(zones []T) { } } -// Get method to retrieve the cached zones +// Get method to retrieve the cached zones. If cache is not expired, this will be used +// instead of making a new API call to get the zones. func (z *zonesCache[T]) Get() []T { return z.zones } -// Expired method to check if the cache has expired based on duration or if zones are empty +// Expired method to check if the cache has expired based on duration or if zones are empty. +// If cache is expired, a new API call will be made to get the zones. If zones are empty, a new +// API call will be made to get the zones. This case comes in at the time of initialization. func (z *zonesCache[T]) Expired() bool { return len(z.zones) < 1 || time.Since(z.age) > z.duration }