Skip to content

Commit

Permalink
Merge pull request #5 from Parker-Kasiewicz/hydrator_updates
Browse files Browse the repository at this point in the history
Adding Error Caching
  • Loading branch information
lxcode authored Oct 10, 2024
2 parents 3d025fc + 96ef537 commit 69e3c4f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/hydrator/hydrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ func (h *Hydrator) LookupIdentity(identifier string) (identity *atpidentity.Iden
cachedValue, found := h.Cache.Get(key)

if found && cachedValue != nil {
if cachedError, isErr := cachedValue.(error); isErr {
log.Debugf("Cached error for %s: %v", identifier, cachedError)
return nil, cachedError // Return the cached error
}
identity = cachedValue.(*atpidentity.Identity)
return
}
Expand All @@ -93,6 +97,7 @@ func (h *Hydrator) LookupIdentity(identifier string) (identity *atpidentity.Iden

identity, err = h.IdentityDirectory.Lookup(h.Context, *resolvedIdentifier)
if err != nil {
h.Cache.SetWithTTL(key, err, 0, time.Duration(1)*time.Hour*24)
return
}

Expand Down

0 comments on commit 69e3c4f

Please sign in to comment.