```
feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
This commit is contained in:
@@ -51,26 +51,6 @@ func newSessionManager() *sessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
// GetSession 通过会话ID获取用户ID
|
||||
func (m *sessionManager) GetSession(sessionID string) (uint32, error) {
|
||||
return m.sessionStore.Get(context.Background(), sessionID)
|
||||
}
|
||||
|
||||
// SaveSession 保存会话信息
|
||||
func (m *sessionManager) SaveSession(sessionID string, userID uint32) error {
|
||||
return m.sessionStore.Set(gctx.New(), sessionID, userID, time.Hour*1)
|
||||
}
|
||||
|
||||
// DeleteSession 删除会话
|
||||
func (m *sessionManager) DeleteSession(sessionID string) error {
|
||||
return m.sessionStore.Del(gctx.New(), sessionID)
|
||||
}
|
||||
|
||||
// SessionExists 检查会话是否存在
|
||||
func (m *sessionManager) SessionExists(sessionID string) (bool, error) {
|
||||
return m.sessionStore.Contains(context.Background(), sessionID)
|
||||
}
|
||||
|
||||
// SetUserOnline 设置用户在线状态
|
||||
func (m *sessionManager) SetUserOnline(userID uint32, serverID uint16) error {
|
||||
return m.userOnlineStore.Set(gctx.New(), gconv.String(userID), serverID, 0)
|
||||
|
||||
Reference in New Issue
Block a user