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

Method SessionUpdate

session/store_runtime.go:56–73  ·  view source on GitHub ↗

SessionUpdate update session state in store

(state *SessionState)

Source from the content-addressed store, hash-verified

54
55// SessionUpdate update session state in store
56func (store *RuntimeStore) SessionUpdate(state *SessionState) error {
57 store.lock.RLock()
58 if element, ok := store.sessions[state.sessionId]; ok { // state has exist
59 go store.SessionAccess(state.sessionId)
60 store.lock.RUnlock()
61 element.Value.(*SessionState).values = state.values // only assist update whole session state
62 return nil
63 }
64 store.lock.RUnlock()
65
66 // if sessionId of state not exist, create a new state
67 new_state := NewSessionState(store, state.sessionId, state.values)
68 store.lock.Lock()
69 new_element := store.list.PushFront(new_state)
70 store.sessions[state.sessionId] = new_element
71 store.lock.Unlock()
72 return nil
73}
74
75// SessionRemove delete session state in store
76func (store *RuntimeStore) SessionRemove(sessionId string) error {

Calls 2

SessionAccessMethod · 0.95
NewSessionStateFunction · 0.85