123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package cache
- import (
- "time"
- "github.com/patrickmn/go-cache"
- "github.com/eryajf/chatgpt-dingtalk/config"
- )
- type UserServiceInterface interface {
-
- GetUserMode(userId string) string
- SetUserMode(userId, mode string)
- ClearUserMode(userId string)
-
- GetUserSessionContext(userId string) string
- SetUserSessionContext(userId, content string)
- ClearUserSessionContext(userId string)
-
- SetUseRequestCount(userId string, current int)
- GetUseRequestCount(uerId string) int
-
- SetAnswerID(userId, chattype string, current uint)
- GetAnswerID(uerId, chattype string) uint
- ClearAnswerID(userId, chattitle string)
- }
- var _ UserServiceInterface = (*UserService)(nil)
- type UserService struct {
-
- cache *cache.Cache
- }
- var Config *config.Configuration
- func NewUserService() UserServiceInterface {
-
- Config = config.LoadConfig()
- return &UserService{cache: cache.New(Config.SessionTimeout, time.Hour*1)}
- }
|