Files
chatgpt-dingtalk/pkg/cache/user_chatid.go
2023-04-11 10:34:53 +08:00

23 lines
644 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cache
import "time"
// SetAnswerID 设置用户获得答案的ID
func (s *UserService) SetAnswerID(userId, chattitle string, current uint) {
s.cache.Set(userId+"_"+chattitle, current, time.Hour*24)
}
// GetAnswerID 获取当前用户获得答案的ID
func (s *UserService) GetAnswerID(userId, chattitle string) uint {
sessionContext, ok := s.cache.Get(userId + "_" + chattitle)
if !ok {
return 0
}
return sessionContext.(uint)
}
// ClearUserSessionContext 清空GPT上下文接收文本中包含 SessionClearToken
func (s *UserService) ClearAnswerID(userId, chattitle string) {
s.cache.Delete(userId + "_" + chattitle)
}