示例#1
0
// Release releases resource and save data to provider.
func (s *MemcacheStore) Release() error {
	data, err := session.EncodeGob(s.data)
	if err != nil {
		return err
	}

	return s.c.Set(NewItem(s.sid, data, s.expire))
}
示例#2
0
文件: redis.go 项目: Xetius/grafana
// Release releases resource and save data to provider.
func (s *RedisStore) Release() error {
	data, err := session.EncodeGob(s.data)
	if err != nil {
		return err
	}

	return s.c.SetEx(s.prefix+s.sid, s.duration, string(data)).Err()
}
示例#3
0
// save postgres session values to database.
// must call this method to save values to database.
func (s *PostgresStore) Release() error {
	data, err := session.EncodeGob(s.data)
	if err != nil {
		return err
	}

	_, err = s.c.Exec("UPDATE session SET data=$1, expiry=$2 WHERE key=$3",
		data, time.Now().Unix(), s.sid)
	return err
}
示例#4
0
// Release releases resource and save data to provider.
func (s *CouchbaseSessionStore) Release() error {
	defer s.b.Close()

	data, err := session.EncodeGob(s.data)
	if err != nil {
		return err
	}

	return s.b.Set(s.sid, int(s.maxlifetime), data)
}
示例#5
0
文件: mysql.go 项目: Xetius/grafana
// Release releases resource and save data to provider.
func (s *MysqlStore) Release() error {
	data, err := session.EncodeGob(s.data)
	if err != nil {
		return err
	}

	_, err = s.c.Exec("UPDATE session SET data=?, expiry=? WHERE `key`=?",
		data, time.Now().Unix(), s.sid)
	return err
}
示例#6
0
文件: ledis.go 项目: Xetius/grafana
// Release releases resource and save data to provider.
func (s *LedisStore) Release() error {
	data, err := session.EncodeGob(s.data)
	if err != nil {
		return err
	}

	if err = s.c.Set([]byte(s.sid), data); err != nil {
		return err
	}
	_, err = s.c.Expire([]byte(s.sid), s.expire)
	return err
}