refactor(cache): remove deprecated unread count methods and keys
All checks were successful
Build Backend / build (push) Successful in 2m5s
Build Backend / build-docker (push) Successful in 1m19s

Clean up the codebase by removing unused and deprecated unread count
functionality in `ConversationCache` and associated Redis key
generators. This follows the transition to sequence-based unread
calculation.

- Remove `IncrementUnread`, `ClearUnread`, `GetUnreadCountFromHash`,
  `GetAllUnreadCounts`, and `GetTotalUnread` from `ConversationCache`.
- Remove `PrefixUnreadHash` and `PrefixUnreadTotal` constants and
  `UnreadHashKey`/`UnreadTotalKey` helper functions.
- Remove unused `isValidContentType` helper in `MessageHandler`.
This commit is contained in:
2026-05-12 18:26:31 +08:00
parent 8d7e8c427b
commit 06db8e36e4
3 changed files with 1 additions and 53 deletions

View File

@@ -692,36 +692,6 @@ func (c *ConversationCache) ComputeAllUnreadCount(ctx context.Context, userID st
return total, nil
}
// IncrementUnread 递增用户在某会话的未读数(已废弃:改用 seq 算术计算)
// Deprecated: Unread count is now computed via arithmetic (maxSeq - readSeq).
func (c *ConversationCache) IncrementUnread(ctx context.Context, userID, convID string) error {
return nil
}
// ClearUnread 清零用户在某会话的未读数(已废弃:改用 seq 算术计算)
// Deprecated: No longer needed. Unread is computed from seq arithmetic.
func (c *ConversationCache) ClearUnread(ctx context.Context, userID, convID string) error {
return nil
}
// GetUnreadCountFromHash 从 Redis Hash 获取单个会话未读数(已废弃)
// Deprecated: Use ComputeUnreadCount instead.
func (c *ConversationCache) GetUnreadCountFromHash(ctx context.Context, userID, convID string) (int64, error) {
return 0, ErrKeyNotFound
}
// GetAllUnreadCounts 从 Redis Hash 获取用户所有会话的未读数(已废弃)
// Deprecated: Use ComputeAllUnreadCount instead.
func (c *ConversationCache) GetAllUnreadCounts(ctx context.Context, userID string) (map[string]int64, error) {
return nil, ErrKeyNotFound
}
// GetTotalUnread 从 Redis 获取用户总未读数(已废弃)
// Deprecated: Use ComputeAllUnreadCount instead.
func (c *ConversationCache) GetTotalUnread(ctx context.Context, userID string) (int64, error) {
return 0, ErrKeyNotFound
}
// GetNextSeq 获取会话的下一个 seq 值(原子递增)
// 使用 Redis INCR 实现,首次调用时从 DB 初始化并补齐差值
func (c *ConversationCache) GetNextSeq(ctx context.Context, convID string) (int64, error) {