SessionRead get session state by sessionId
(sessionId string)
| 25 | |
| 26 | // SessionRead get session state by sessionId |
| 27 | func (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 |
| 46 | func (store *RuntimeStore) SessionExist(sessionId string) bool { |