From f6bafb14e1cdfaf58fa71dc6c0ec7dc9ca4883c7 Mon Sep 17 00:00:00 2001 From: tanujd11 Date: Thu, 17 Oct 2024 01:48:38 +0530 Subject: [PATCH] addressed review comments Signed-off-by: tanujd11 --- provider/azure/cache.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 }