lab2: review round 2 — cache versioning, UUID normalization, cursor validation, benchmark evidence

This commit is contained in:
2026-10-10 08:13:56 +03:00
parent 24fe6e23d2
commit 3dca6ff635
3 changed files with 10 additions and 17 deletions
+2 -2
View File
@@ -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