将go Httpserver.Run() 挪到 routeregister方法
This commit is contained in:
@@ -567,9 +567,9 @@ const (
|
||||
ConversationCacheExpireSeconds = 600
|
||||
)
|
||||
|
||||
// CacheConversation 缓存单条对话到Redis List
|
||||
func CacheConversation(ctx context.Context, userId, platform string, data []byte) error {
|
||||
key := ConversationCacheKeyPrefix + userId + "_" + platform
|
||||
// CacheConversation 缓存单条对话到Redis List(按sessionId存储)
|
||||
func CacheConversation(ctx context.Context, sessionId string, data []byte) error {
|
||||
key := ConversationCacheKeyPrefix + sessionId
|
||||
_, err := redisClient.Do(ctx, "RPUSH", key, string(data))
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -578,9 +578,9 @@ func CacheConversation(ctx context.Context, userId, platform string, data []byte
|
||||
return err
|
||||
}
|
||||
|
||||
// GetCachedConversations 获取缓存的对话列表并清空
|
||||
func GetCachedConversations(ctx context.Context, userId, platform string) (list []string, err error) {
|
||||
key := ConversationCacheKeyPrefix + userId + "_" + platform
|
||||
// GetCachedConversations 获取缓存的对话列表并清空(按sessionId查询)
|
||||
func GetCachedConversations(ctx context.Context, sessionId string) (list []string, err error) {
|
||||
key := ConversationCacheKeyPrefix + sessionId
|
||||
result, err := redisClient.Do(ctx, "LRANGE", key, 0, -1)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -594,9 +594,9 @@ func GetCachedConversations(ctx context.Context, userId, platform string) (list
|
||||
return
|
||||
}
|
||||
|
||||
// GetCachedConversationCount 获取缓存的对话数量
|
||||
func GetCachedConversationCount(ctx context.Context, userId, platform string) (count int64, err error) {
|
||||
key := ConversationCacheKeyPrefix + userId + "_" + platform
|
||||
// GetCachedConversationCount 获取缓存的对话数量(按sessionId查询)
|
||||
func GetCachedConversationCount(ctx context.Context, sessionId string) (count int64, err error) {
|
||||
key := ConversationCacheKeyPrefix + sessionId
|
||||
result, err := redisClient.Do(ctx, "LLEN", key)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -604,9 +604,9 @@ func GetCachedConversationCount(ctx context.Context, userId, platform string) (c
|
||||
return result.Int64(), nil
|
||||
}
|
||||
|
||||
// ClearCachedConversations 清空对话缓存(归档时调用)
|
||||
func ClearCachedConversations(ctx context.Context, userId, platform string) error {
|
||||
key := ConversationCacheKeyPrefix + userId + "_" + platform
|
||||
// ClearCachedConversations 清空对话缓存(归档时调用,按sessionId)
|
||||
func ClearCachedConversations(ctx context.Context, sessionId string) error {
|
||||
key := ConversationCacheKeyPrefix + sessionId
|
||||
_, err := redisClient.Del(ctx, key)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user