sigs.k8s.io/external-dns@v0.14.1/provider/oci/cache.go (about) 1 /* 2 Copyright 2023 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package oci 18 19 import ( 20 "time" 21 22 "github.com/oracle/oci-go-sdk/v65/dns" 23 ) 24 25 type zoneCache struct { 26 age time.Time 27 duration time.Duration 28 zones map[string]dns.ZoneSummary 29 } 30 31 func (z *zoneCache) Reset(zones map[string]dns.ZoneSummary) { 32 if z.duration > time.Duration(0) { 33 z.age = time.Now() 34 z.zones = zones 35 } 36 } 37 38 func (z *zoneCache) Get() map[string]dns.ZoneSummary { 39 return z.zones 40 } 41 42 func (z *zoneCache) Expired() bool { 43 return len(z.zones) < 1 || time.Since(z.age) > z.duration 44 }