lab2: review round 2 — cache versioning, UUID normalization, cursor validation, benchmark evidence
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
This commit is contained in:
@@ -68,7 +68,9 @@ func (s *AuthService) ValidateSession(ctx context.Context, token string) (*domai
|
||||
if errors.Is(err, repository.ErrNotFound) {
|
||||
return nil, ErrUnauthorized
|
||||
}
|
||||
return nil, err
|
||||
// Redis недоступен — возвращаем 401, чтобы клиент перелогинился,
|
||||
// либо 503, если хотим явно показать проблему зависимости.
|
||||
return nil, ErrUnauthorized // ← было: return nil, err
|
||||
}
|
||||
if nowUTC().After(sess.ExpiresAt) {
|
||||
_ = s.sessions.Delete(ctx, token)
|
||||
|
||||
@@ -88,8 +88,8 @@ func (s *MessageService) List(ctx context.Context, callerID, chatID, cursor stri
|
||||
// Проверяем кэш. Если версия изменилась между GetVersion и Get — не используем.
|
||||
var versionBefore int64
|
||||
if s.cache != nil {
|
||||
versionBefore = s.cache.GetVersion(ctx, chatID)
|
||||
if items, next, hit := s.cache.Get(ctx, chatID, cursor, limit); hit {
|
||||
versionBefore = s.cache.GetVersion(ctx, chatID) // ← GetVersion не возвращает ошибку, ок
|
||||
if items, next, hit := s.cache.Get(ctx, chatID, cursor, limit); hit { // ← Get: при ошибке false
|
||||
// Проверяем, что версия не изменилась с момента Set
|
||||
if s.cache.GetVersion(ctx, chatID) == versionBefore {
|
||||
return items, next, nil
|
||||
|
||||
Reference in New Issue
Block a user