Skip to content

Commit

Permalink
client/tokens: fix cache hit return (#77)
Browse files Browse the repository at this point in the history
lol

## Test plan

CI
  • Loading branch information
bobheadxi authored Nov 28, 2024
1 parent 8e3c388 commit 8ad5975
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion clientv1_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ type IntrospectTokenResponse struct {
// `.Active == false`.
func (s *TokensServiceV1) IntrospectToken(ctx context.Context, token string) (*IntrospectTokenResponse, error) {
if s.introspectTokenCache != nil {
if cached, ok := s.introspectTokenCache.Get(token); ok && cached.ExpiresAt.Before(time.Now()) {
if cached, ok := s.introspectTokenCache.Get(token); ok && // entry exists
// and NOT expired
cached.ExpiresAt.After(time.Now()) {
trace.SpanFromContext(ctx).
SetAttributes(attribute.Bool("sams.introspectToken.fromCache", true))
return cached, nil
Expand Down

0 comments on commit 8ad5975

Please sign in to comment.