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

Method SessionRead

session/store_runtime.go:27–43  ·  view source on GitHub ↗

SessionRead get session state by sessionId

(sessionId string)

Source from the content-addressed store, hash-verified

25
26// SessionRead get session state by sessionId
27func (store *RuntimeStore) SessionRead(sessionId string) (*SessionState, error) {
28 store.lock.RLock()
29 if element, ok := store.sessions[sessionId]; ok {
30 go store.SessionAccess(sessionId)
31 store.lock.RUnlock()
32 return element.Value.(*SessionState), nil
33 }
34 store.lock.RUnlock()
35
36 // if sessionId of state not exist, create a new state
37 state := NewSessionState(store, sessionId, make(map[interface{}]interface{}))
38 store.lock.Lock()
39 element := store.list.PushFront(state)
40 store.sessions[sessionId] = element
41 store.lock.Unlock()
42 return state, nil
43}
44
45// SessionExist check session state exist by sessionId
46func (store *RuntimeStore) SessionExist(sessionId string) bool {

Calls 2

SessionAccessMethod · 0.95
NewSessionStateFunction · 0.85