-
Notifications
You must be signed in to change notification settings - Fork 1
/
pool.go
34 lines (28 loc) · 800 Bytes
/
pool.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
package gorillaradix
import (
"github.com/gorilla/securecookie"
"github.com/gorilla/sessions"
"github.com/mediocregopher/radix/v3"
)
// Vanilla Redis specific options
type PoolConfiguration struct {
ConnectionOptions
Host string
}
func NewStore(configuration PoolConfiguration, options SessionOptions) (sessions.Store, error) {
connectFunction := createRadixConnectionFunction(configuration.ConnectionOptions)
pool, err := radix.NewPool(
"tcp",
configuration.Host,
10,
radix.PoolConnFunc(connectFunction),
radix.PoolPingInterval(configuration.PingTimeout),
)
applyDefaultSessionConfiguration(&options)
return &RadixStore{
redis: pool,
Codecs: securecookie.CodecsFromPairs([]byte(options.Secret)),
Options: options,
serializer: GobSerializer{},
}, err
}