// save session values to memcache func (rs *MemcacheSessionStore) SessionRelease(w http.ResponseWriter) { b, err := session.EncodeGob(rs.values) if err != nil { return } item := memcache.Item{Key: rs.sid, Value: b, Expiration: int32(rs.maxlifetime)} client.Set(&item) }
// save session values to ledis func (ls *LedisSessionStore) SessionRelease(w http.ResponseWriter) { b, err := session.EncodeGob(ls.values) if err != nil { return } c.Set([]byte(ls.sid), b) c.Expire([]byte(ls.sid), ls.maxlifetime) }
func (cs *CouchbaseSessionStore) SessionRelease(w http.ResponseWriter) { defer cs.b.Close() bo, err := session.EncodeGob(cs.values) if err != nil { return } cs.b.Set(cs.sid, int(cs.maxlifetime), bo) }
// save mysql session values to database. // must call this method to save values to database. func (st *MysqlSessionStore) SessionRelease(w http.ResponseWriter) { defer st.c.Close() b, err := session.EncodeGob(st.values) if err != nil { return } st.c.Exec("UPDATE session set `session_data`=?, `session_expiry`=? where session_key=?", b, time.Now().Unix(), st.sid) }
// save postgresql session values to database. // must call this method to save values to database. func (st *PostgresqlSessionStore) SessionRelease(w http.ResponseWriter) { defer st.c.Close() b, err := session.EncodeGob(st.values) if err != nil { return } st.c.Exec("UPDATE session set session_data=$1, session_expiry=$2 where session_key=$3", b, time.Now().Format(time.RFC3339), st.sid) }
// save session values to redis func (rs *RedisSessionStore) SessionRelease(w http.ResponseWriter) { c := rs.p.Get() defer c.Close() b, err := session.EncodeGob(rs.values) if err != nil { return } c.Do("SETEX", rs.sid, rs.maxlifetime, string(b)) }