SessionUpdate update session state in store
(state *SessionState)
| 54 | |
| 55 | // SessionUpdate update session state in store |
| 56 | func (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 |
| 76 | func (store *RuntimeStore) SessionRemove(sessionId string) error { |