Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
f1573279
Unverified
Commit
f1573279
authored
Jul 20, 2018
by
astaxie
Committed by
GitHub
Jul 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3239 from wilhelmguo/develop
add session redis IdleTimeout config
parents
efbe655d
6fec0a78
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
sess_redis.go
session/redis/sess_redis.go
+13
-3
No files found.
session/redis/sess_redis.go
View file @
f1573279
...
...
@@ -37,6 +37,7 @@ import (
"strconv"
"strings"
"sync"
"time"
"github.com/astaxie/beego/session"
...
...
@@ -118,8 +119,8 @@ type Provider struct {
}
// SessionInit init redis session
// savepath like redis server addr,pool size,password,dbnum
// e.g. 127.0.0.1:6379,100,astaxie,0
// savepath like redis server addr,pool size,password,dbnum
,IdleTimeout second
// e.g. 127.0.0.1:6379,100,astaxie,0
,30
func
(
rp
*
Provider
)
SessionInit
(
maxlifetime
int64
,
savePath
string
)
error
{
rp
.
maxlifetime
=
maxlifetime
configs
:=
strings
.
Split
(
savePath
,
","
)
...
...
@@ -149,6 +150,13 @@ func (rp *Provider) SessionInit(maxlifetime int64, savePath string) error {
}
else
{
rp
.
dbNum
=
0
}
var
idleTimeout
time
.
Duration
=
0
if
len
(
configs
)
>
4
{
timeout
,
err
:=
strconv
.
Atoi
(
configs
[
4
])
if
err
==
nil
&&
timeout
>
0
{
idleTimeout
=
time
.
Duration
(
timeout
)
*
time
.
Second
}
}
rp
.
poollist
=
&
redis
.
Pool
{
Dial
:
func
()
(
redis
.
Conn
,
error
)
{
c
,
err
:=
redis
.
Dial
(
"tcp"
,
rp
.
savePath
)
...
...
@@ -171,9 +179,11 @@ func (rp *Provider) SessionInit(maxlifetime int64, savePath string) error {
}
return
c
,
err
},
MaxIdle
:
rp
.
poolsize
,
MaxIdle
:
rp
.
poolsize
,
}
rp
.
poollist
.
IdleTimeout
=
idleTimeout
return
rp
.
poollist
.
Get
()
.
Err
()
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment