Skip to content

Commit 338e5c4

Browse files
author
胡子豪
authored
Update 06.2.md
fix session销毁的*Manager#GC()直接执行
1 parent 72d959b commit 338e5c4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

zh/06.2.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ func init() {
217217
func (manager *Manager) GC() {
218218
manager.lock.Lock()
219219
defer manager.lock.Unlock()
220-
manager.provider.SessionGC(manager.maxLifeTime)
221-
time.AfterFunc(time.Duration(manager.maxLifeTime), func() { manager.GC() })
220+
time.AfterFunc(time.Duration(manager.maxLifeTime), func() { manager.provider.SessionGC(manager.maxLifeTime) })
222221
}
223222
```
224223
我们可以看到GC充分利用了time包中的定时器功能,当超时`maxLifeTime`之后调用GC函数,这样就可以保证`maxLifeTime`时间内的session都是可用的,类似的方案也可以用于统计在线用户数之类的。

0 commit comments

Comments
 (0)