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
d46833c6
Commit
d46833c6
authored
Jan 09, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #997 from dockercn/master
增加session模块中的ledisdb的动态配置
parents
5d8187d0
29d98731
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
ledis_session.go
session/ledis/ledis_session.go
+15
-3
No files found.
session/ledis/ledis_session.go
View file @
d46833c6
...
...
@@ -2,6 +2,8 @@ package session
import
(
"net/http"
"strconv"
"strings"
"sync"
"github.com/astaxie/beego/session"
...
...
@@ -74,19 +76,29 @@ func (ls *LedisSessionStore) SessionRelease(w http.ResponseWriter) {
type
LedisProvider
struct
{
maxlifetime
int64
savePath
string
db
int
}
// init ledis session
// savepath like ledis server saveDataPath,pool size
// e.g. 127.0.0.1:6379,100,astaxie
func
(
lp
*
LedisProvider
)
SessionInit
(
maxlifetime
int64
,
savePath
string
)
error
{
var
err
error
lp
.
maxlifetime
=
maxlifetime
lp
.
savePath
=
savePath
configs
:=
strings
.
Split
(
savepath
,
","
)
if
len
(
configs
)
==
1
{
lp
.
savePath
=
configs
[
0
]
}
else
if
len
(
configs
)
==
2
{
lp
.
savePath
=
configs
[
0
]
lp
.
db
,
err
=
strconv
.
Atoi
(
configs
[
1
])
if
err
!=
nil
{
return
err
}
}
cfg
:=
new
(
config
.
Config
)
cfg
.
DataDir
=
lp
.
savePath
var
err
error
nowLedis
,
err
:=
ledis
.
Open
(
cfg
)
c
,
err
=
nowLedis
.
Select
(
0
)
c
,
err
=
nowLedis
.
Select
(
lp
.
db
)
if
err
!=
nil
{
println
(
err
)
return
nil
...
...
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