mirror of
https://github.com/eryajf/chatgpt-dingtalk.git
synced 2025-10-09 01:50:09 +08:00
feat: add user request limit config (#98)
This commit is contained in:
22
pkg/cache/user_mode.go
vendored
Normal file
22
pkg/cache/user_mode.go
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
package cache
|
||||
|
||||
import "github.com/patrickmn/go-cache"
|
||||
|
||||
// GetUserMode 获取当前对话模式
|
||||
func (s *UserService) GetUserMode(userId string) string {
|
||||
sessionContext, ok := s.cache.Get(userId + "_mode")
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return sessionContext.(string)
|
||||
}
|
||||
|
||||
// SetUserMode 设置用户对话模式
|
||||
func (s *UserService) SetUserMode(userId string, mode string) {
|
||||
s.cache.Set(userId+"_mode", mode, cache.DefaultExpiration)
|
||||
}
|
||||
|
||||
// ClearUserMode 重置用户对话模式
|
||||
func (s *UserService) ClearUserMode(userId string) {
|
||||
s.cache.Delete(userId + "_mode")
|
||||
}
|
Reference in New Issue
Block a user