func (this *RedisStore) Set(sess *Session) error {
	b, err := json.Marshal(sess)
	if err != nil {
		return err
	}
	key := sess.ID()
	if this.opts.KeyPrefix != "" {
		key = this.opts.KeyPrefix + ":" + sess.ID()
	}
	ttl := sess.MaxAge()
	if ttl == 0 {
		ttl = this.opts.BrowserSessServerTTL
		if ttl == 0 {
			ttl = 2 * 24 * time.Hour  
		}
	}
	_, err = this.conn.Do("SETEX", key, int(ttl.Seconds()), b)
	if err != nil {
		return err
	}
	return nil
}
Save the session into the store.
package handlers
import (
	"encoding/json"
	"errors"
	"time"
	"github.com/garyburd/redigo/redis"
)
var (
	ErrNoKeyPrefix = errors.New("cannot get session keys without a key prefix")
)
type RedisStoreOptions struct {
	Network              string
	Address              string
	ConnectTimeout       time.Duration
	ReadTimeout          time.Duration
	WriteTimeout         time.Duration
	Database             int            
	KeyPrefix            string         
	BrowserSessServerTTL time.Duration  
}
type RedisStore struct {
	opts *RedisStoreOptions
	conn redis.Conn
}
func NewRedisStore(opts *RedisStoreOptions) *RedisStore {
	var err error
	rs := &RedisStore{opts, nil}
	rs.conn, err = redis.DialTimeout(opts.Network, opts.Address, opts.ConnectTimeout,
		opts.ReadTimeout, opts.WriteTimeout)
	if err != nil {
		panic(err)
	}
	return rs
}
func (this *RedisStore) Get(id string) (*Session, error) {
	key := id
	if this.opts.KeyPrefix != "" {
		key = this.opts.KeyPrefix + ":" + id
	}
	b, err := redis.Bytes(this.conn.Do("GET", key))
	if err != nil {
		return nil, err
	}
	var sess Session
	err = json.Unmarshal(b, &sess)
	if err != nil {
		return nil, err
	}
	return &sess, nil
}