mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 09:36:58 +02:00
addressed review comments
Signed-off-by: tanujd11 <dwiveditanuj41@gmail.com>
This commit is contained in:
parent
faced93ba2
commit
f6bafb14e1
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user