Пример #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
// 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
// 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
// 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
}