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

Method SessionRead

session/store_redis.go:64–87  ·  view source on GitHub ↗

SessionRead get session state by sessionId

(sessionId string)

Source from the content-addressed store, hash-verified

62
63// SessionRead get session state by sessionId
64func (store *RedisStore) SessionRead(sessionId string) (*SessionState, error) {
65 redisClient := store.getRedisClient()
66 key := store.getRedisKey(sessionId)
67 kvs, err := redisClient.Get(key)
68 if store.checkConnErrorAndNeedRetry(err) {
69 redisClient = store.getBackupRedis()
70 kvs, err = redisClient.Get(key)
71 }
72 if err != nil {
73 return nil, err
74 }
75 var kv map[interface{}]interface{}
76 if len(kvs) == 0 {
77 kv = make(map[interface{}]interface{})
78 } else {
79 kv, err = gob.DecodeMap([]byte(kvs))
80 if err != nil {
81 return nil, err
82 }
83 }
84 state := NewSessionState(store, sessionId, kv)
85 go store.sessionReExpire(state)
86 return state, nil
87}
88
89// SessionExist check session state exist by sessionId
90func (store *RedisStore) SessionExist(sessionId string) bool {

Callers

nothing calls this directly

Calls 8

getRedisClientMethod · 0.95
getRedisKeyMethod · 0.95
getBackupRedisMethod · 0.95
sessionReExpireMethod · 0.95
DecodeMapFunction · 0.92
NewSessionStateFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected