diff options
Diffstat (limited to 'internal/source/gitlab/cache/cache.go')
-rw-r--r-- | internal/source/gitlab/cache/cache.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/internal/source/gitlab/cache/cache.go b/internal/source/gitlab/cache/cache.go index 85f44e11..3d518ff0 100644 --- a/internal/source/gitlab/cache/cache.go +++ b/internal/source/gitlab/cache/cache.go @@ -4,6 +4,7 @@ import ( "context" "gitlab.com/gitlab-org/gitlab-pages/internal/source/gitlab/api" + "gitlab.com/gitlab-org/gitlab-pages/metrics" ) // Cache is a short and long caching mechanism for GitLab source @@ -20,7 +21,7 @@ func NewCache(client api.Client) *Cache { } } -// Resolve is going to return a Lookup based on a domain name. The caching +// Resolve is going to return a lookup based on a domain name. The caching // algorithm works as follows: // - We first check if the cache entry exists, and if it is up-to-date. If it // is fresh we return the lookup entry from cache and it is a cache hit. @@ -73,19 +74,17 @@ func (c *Cache) Resolve(ctx context.Context, domain string) *api.Lookup { entry := c.store.LoadOrCreate(domain) if entry.IsUpToDate() { + metrics.DomainsSourceCacheHit.Inc() return entry.Lookup() } if entry.NeedsRefresh() { entry.Refresh(c.client, c.store) + metrics.DomainsSourceCacheHit.Inc() return entry.Lookup() } + metrics.DomainsSourceCacheMiss.Inc() return entry.Retrieve(ctx, c.client) } - -// New creates a new instance of Cache and sets default expiration -func New() *Cache { - return &Cache{} -} |