1
This commit is contained in:
49
keyBoard/Class/AiTalk/M/KBAIChatMessageCacheManager.h
Normal file
49
keyBoard/Class/AiTalk/M/KBAIChatMessageCacheManager.h
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// KBAIChatMessageCacheManager.h
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Mac on 2026/1/28.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class KBAiChatMessage;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 聊天消息缓存管理器
|
||||
/// 用于避免重复请求消息数据,提升性能
|
||||
@interface KBAIChatMessageCacheManager : NSObject
|
||||
|
||||
/// 单例
|
||||
+ (instancetype)shared;
|
||||
|
||||
/// 保存消息到缓存
|
||||
/// @param messages 消息数组
|
||||
/// @param companionId 人设 ID
|
||||
- (void)saveMessages:(NSArray<KBAiChatMessage *> *)messages forCompanionId:(NSInteger)companionId;
|
||||
|
||||
/// 从缓存获取消息
|
||||
/// @param companionId 人设 ID
|
||||
/// @return 消息数组,如果缓存中没有则返回 nil
|
||||
- (NSArray<KBAiChatMessage *> * _Nullable)messagesForCompanionId:(NSInteger)companionId;
|
||||
|
||||
/// 追加消息到缓存(用于上拉加载更多历史消息)
|
||||
/// @param messages 新消息数组
|
||||
/// @param companionId 人设 ID
|
||||
- (void)appendMessages:(NSArray<KBAiChatMessage *> *)messages forCompanionId:(NSInteger)companionId;
|
||||
|
||||
/// 清空指定人设的消息缓存
|
||||
/// @param companionId 人设 ID
|
||||
- (void)clearMessagesForCompanionId:(NSInteger)companionId;
|
||||
|
||||
/// 清空所有消息缓存
|
||||
- (void)clearAllMessages;
|
||||
|
||||
/// 获取缓存状态
|
||||
/// @param companionId 人设 ID
|
||||
/// @return 是否有缓存
|
||||
- (BOOL)hasCacheForCompanionId:(NSInteger)companionId;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Reference in New Issue
Block a user