forked from martini-contrib/sessions
/
redis_store.go
46 lines (38 loc) · 1.31 KB
/
redis_store.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package sessions
import (
"github.com/boj/redistore"
"github.com/garyburd/redigo/redis"
)
type RedisStore interface {
Store
Options(Options)
}
// NewRediStore returns a new RediStore.
// size: maximum number of idle connections.
func NewRediStore(size int, network, address, password string, keyPairs []byte) *redisStore {
store, _ := redistore.NewRediStore(size, network, address, password, keyPairs)
return &redisStore{store}
}
// NewRedisStoreWithDB - like NewRedisStore but accepts `DB` parameter to select
// redis DB instead of using the default one ("0")
func NewRediStoreWithDB(size int, network string, address, password, DB string, keyPairs []byte) *redisStore {
store, _ := redistore.NewRediStoreWithDB(size, network, address, password, DB, keyPairs)
return &redisStore{store}
}
// NewRediStoreWithPool instantiates a RediStore with a *redis.Pool passed in.
func NewRediStoreWithPool(pool *redis.Pool, keyPairs []byte) *redisStore {
store, _ := redistore.NewRediStoreWithPool(pool, keyPairs)
return &redisStore{store}
}
type redisStore struct {
*redistore.RediStore
}
// func (r *redisStore) Options(options Options) {
// r.daf = sessions.Options{
// Path: options.Path,
// Domain: options.Domain,
// MaxAge: options.MaxAge,
// Secure: options.Secure,
// HttpOnly: options.HttpOnly,
// }
// }