File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed
Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ type redisStore struct {
2929// newRedisStore returns a new Redis session store based on given configuration.
3030func newRedisStore (cfg Config ) * redisStore {
3131 return & redisStore {
32- client : cfg .client ,
32+ client : cfg .Client ,
3333 keyPrefix : cfg .KeyPrefix ,
3434 lifetime : cfg .Lifetime ,
3535 encoder : cfg .Encoder ,
@@ -92,9 +92,9 @@ type Options = redis.Options
9292
9393// Config contains options for the Redis session store.
9494type Config struct {
95- // For tests only
96- client * redis. Client
97-
95+ // Client is the Redis Client connection. If not set, a new client will be
96+ // created based on Options.
97+ Client * redis. Client
9898 // Options is the settings to set up Redis client connection.
9999 Options * Options
100100 // KeyPrefix is the prefix to use for keys in Redis. Default is "session:".
@@ -121,14 +121,13 @@ func Initer() session.Initer {
121121
122122 if cfg == nil {
123123 return nil , fmt .Errorf ("config object with the type '%T' not found" , Config {})
124- } else if cfg .Options == nil && cfg .client == nil {
124+ } else if cfg .Options == nil && cfg .Client == nil {
125125 return nil , errors .New ("empty Options" )
126126 }
127127
128- if cfg .client == nil {
129- cfg .client = redis .NewClient (cfg .Options )
128+ if cfg .Client == nil {
129+ cfg .Client = redis .NewClient (cfg .Options )
130130 }
131-
132131 if cfg .KeyPrefix == "" {
133132 cfg .KeyPrefix = "session:"
134133 }
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ func TestRedisStore(t *testing.T) {
7373 session.Options {
7474 Initer : Initer (),
7575 Config : Config {
76- client : client ,
76+ Client : client ,
7777 },
7878 },
7979 ))
@@ -137,7 +137,7 @@ func TestRedisStore_GC(t *testing.T) {
137137
138138 store , err := Initer ()(ctx ,
139139 Config {
140- client : client ,
140+ Client : client ,
141141 Lifetime : time .Second ,
142142 },
143143 )
@@ -174,7 +174,7 @@ func TestRedisStore_Touch(t *testing.T) {
174174
175175 store , err := Initer ()(ctx ,
176176 Config {
177- client : client ,
177+ Client : client ,
178178 Lifetime : time .Second ,
179179 },
180180 )
You can’t perform that action at this time.
0 commit comments