Auth: Cache Auth Info (#80620)

* leverage cache for auth info

* fix tests and integration

* fix panic

* fix panic
This commit is contained in:
Jo
2024-01-18 15:22:19 +01:00
committed by GitHub
parent e77dbb63e3
commit c767481dee
4 changed files with 150 additions and 14 deletions
+10 -1
View File
@@ -3,6 +3,7 @@ package remotecache
import (
"context"
"crypto/tls"
"errors"
"fmt"
"strconv"
"strings"
@@ -93,7 +94,15 @@ func (s *redisStorage) Set(ctx context.Context, key string, data []byte, expires
// GetByteArray returns the value as byte array
func (s *redisStorage) Get(ctx context.Context, key string) ([]byte, error) {
return s.c.Get(ctx, key).Bytes()
item, err := s.c.Get(ctx, key).Bytes()
if err != nil {
if errors.Is(err, redis.Nil) {
return nil, ErrCacheItemNotFound
}
return nil, err
}
return item, nil
}
// Delete delete a key from session.