Documentation ¶
Index ¶
- Constants
- Variables
- func CreatSession(session *Session) bool
- func GetSessionsByUserId(userId string) (*[]Session, error)
- func IsExistSession(sessionId string) bool
- func RemoveSessionById(id string) bool
- func RemoveSessionByUserId(usreId string) bool
- func ScanSession()
- func SetSessionStat(sessionId, state string) bool
- func TickerTaskUpdateSession(sessionId string, tickerFlagStop chan bool)
- func UpdateSessionUpdated(sessionId string, updated time.Time) bool
- func UpdateSessionUserID(sessionId, userId string) bool
- type Session
Constants ¶
View Source
const ( SESSION_STATE_INIT = "init" SESSION_STATE_ACTIVE = "active" SESSION_STATE_INACTIVE = "inactive" INSERT_SESSION = "INSERT INTO `session`(`id`,`type`,`user_id`,`state`,`created`,`updated`) VALUES (?,?,?,?,?,?) " DELETE_SESSION_BYID = "DELETE FROM `session` WHERE `id`=?" DELETE_SESSION_BYUSERID = "DELETE FROM `session` WHERE `user_id`=?" UPDATE_SESSION_UPDATED = "UPDATE `session` SET `updated` = ? WHERE `id`=? " UPDATE_SESSION_STATE = "UPDATE `session` SET `state` = ? WHERE `id`=? " DELETE_SESSION_PAST = "DELETE FROM `session` WHERE `updated` < ?" SET_USERID = "UPDATE `session` SET `user_id` = ? WHERE `id` = ?" SELECT_SESSION_BYSTATE = "SELECT `id`,`type`,`user_id`,`state`,`created`,`updated` FROM SESSION WHERE `user_id`=? AND `state`=?" SELECT_SESSION_BYUSERID = "SELECT `id`,`type`,`user_id`,`state`,`created`,`updated` FROM SESSION WHERE `user_id` = ?" SELECT_SESSION_BYID = "SELECT `id`,`type`,`user_id`,`state`,`created`,`updated` FROM SESSION WHERE `id`=?" SELECT_SESSION_BYIDS = "SELECT `id`,`type`,`user_id`,`state`,`created`,`updated` FROM SESSION WHERE `id`IN (?)" EXIST_SESSION = "SELECT id FROM session WHERE id = ?" )
Variables ¶
View Source
var ScanSessionTime = time.NewTicker(168 * time.Hour)
一个星期扫描一次
Functions ¶
func GetSessionsByUserId ¶
通过userd查询会话session
func IsExistSession ¶ added in v1.2.0
func TickerTaskUpdateSession ¶
定时更新会话session时间
func UpdateSessionUpdated ¶
更新会话session的最新时间
Types ¶
type Session ¶
type Session struct { Id string `json:"id"` Type string `json:"type"` UserId string `json:"userId"` State string `json:"sate"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` }
func GetSessions ¶
根据 args 参数获取用户 uid 的会话集.
args 参数:
- ["all"] 表示获取该用户所有的会话
- ["xxx1", "xxx2"] 表示获取该用户 xxx1、xxx2 会话
- ["active"] 表示获取该用户的所有激活的会话
- [inactive"] 表示获取该用户的所有非激活的会话
Click to show internal directories.
Click to hide internal directories.