MCPcopy Create free account
hub / github.com/devfeel/dotweb / SessionGC

Method SessionGC

session/store_runtime.go:88–110  ·  view source on GitHub ↗

SessionGC clean expired session stores in memory session

()

Source from the content-addressed store, hash-verified

86
87// SessionGC clean expired session stores in memory session
88func (store *RuntimeStore) SessionGC() int {
89 num := 0
90 store.lock.RLock()
91 for {
92 element := store.list.Back()
93 if element == nil {
94 break
95 }
96 if (element.Value.(*SessionState).timeAccessed.Unix() + store.maxlifetime) < time.Now().Unix() {
97 store.lock.RUnlock()
98 store.lock.Lock()
99 store.list.Remove(element)
100 delete(store.sessions, element.Value.(*SessionState).SessionID())
101 num += 1
102 store.lock.Unlock()
103 store.lock.RLock()
104 } else {
105 break
106 }
107 }
108 store.lock.RUnlock()
109 return num
110}
111
112// SessionAll get count number of memory session
113func (store *RuntimeStore) SessionCount() int {

Callers

nothing calls this directly

Calls 2

RemoveMethod · 0.65
SessionIDMethod · 0.65

Tested by

no test coverage detected