Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
二次元的罪恶王冠
beego
提交
7267f5e5
B
beego
项目概览
二次元的罪恶王冠
/
beego
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
beego
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7267f5e5
编写于
8月 11, 2020
作者:
P
Phillip Stagnet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new config option into provider struct
上级
d1d9df74
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
54 addition
and
55 deletion
+54
-55
pkg/session/redis/sess_redis.go
pkg/session/redis/sess_redis.go
+15
-16
pkg/session/redis_cluster/redis_cluster.go
pkg/session/redis_cluster/redis_cluster.go
+18
-18
pkg/session/redis_sentinel/sess_redis_sentinel.go
pkg/session/redis_sentinel/sess_redis_sentinel.go
+21
-21
未找到文件。
pkg/session/redis/sess_redis.go
浏览文件 @
7267f5e5
...
...
@@ -109,12 +109,15 @@ func (rs *SessionStore) SessionRelease(w http.ResponseWriter) {
// Provider redis session provider
type
Provider
struct
{
maxlifetime
int64
savePath
string
poolsize
int
password
string
dbNum
int
poollist
*
redis
.
Client
maxlifetime
int64
savePath
string
poolsize
int
password
string
dbNum
int
idleTimeout
time
.
Duration
idleCheckFrequency
time
.
Duration
maxRetries
int
poollist
*
redis
.
Client
}
// SessionInit init redis session
...
...
@@ -149,25 +152,22 @@ 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
.
idleTimeout
=
time
.
Duration
(
timeout
)
*
time
.
Second
}
}
var
idleCheckFrequency
time
.
Duration
=
0
if
len
(
configs
)
>
5
{
checkFrequency
,
err
:=
strconv
.
Atoi
(
configs
[
5
])
if
err
==
nil
&&
checkFrequency
>
0
{
idleCheckFrequency
=
time
.
Duration
(
checkFrequency
)
*
time
.
Second
rp
.
idleCheckFrequency
=
time
.
Duration
(
checkFrequency
)
*
time
.
Second
}
}
var
maxRetries
=
0
if
len
(
configs
)
>
6
{
retries
,
err
:=
strconv
.
Atoi
(
configs
[
6
])
if
err
==
nil
&&
retries
>
0
{
maxRetries
=
retries
rp
.
maxRetries
=
retries
}
}
...
...
@@ -176,9 +176,9 @@ func (rp *Provider) SessionInit(maxlifetime int64, savePath string) error {
Password
:
rp
.
password
,
PoolSize
:
rp
.
poolsize
,
DB
:
rp
.
dbNum
,
IdleTimeout
:
idleTimeout
,
IdleCheckFrequency
:
idleCheckFrequency
,
MaxRetries
:
maxRetries
,
IdleTimeout
:
rp
.
idleTimeout
,
IdleCheckFrequency
:
rp
.
idleCheckFrequency
,
MaxRetries
:
rp
.
maxRetries
,
})
return
rp
.
poollist
.
Ping
()
.
Err
()
...
...
@@ -249,4 +249,3 @@ func (rp *Provider) SessionAll() int {
func
init
()
{
session
.
Register
(
"redis"
,
redispder
)
}
pkg/session/redis_cluster/redis_cluster.go
浏览文件 @
7267f5e5
...
...
@@ -107,12 +107,15 @@ func (rs *SessionStore) SessionRelease(w http.ResponseWriter) {
// Provider redis_cluster session provider
type
Provider
struct
{
maxlifetime
int64
savePath
string
poolsize
int
password
string
dbNum
int
poollist
*
rediss
.
ClusterClient
maxlifetime
int64
savePath
string
poolsize
int
password
string
dbNum
int
idleTimeout
time
.
Duration
idleCheckFrequency
time
.
Duration
maxRetries
int
poollist
*
rediss
.
ClusterClient
}
// SessionInit init redis_cluster session
...
...
@@ -147,35 +150,32 @@ 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
.
idleTimeout
=
time
.
Duration
(
timeout
)
*
time
.
Second
}
}
var
idleCheckFrequency
time
.
Duration
=
0
if
len
(
configs
)
>
5
{
checkFrequency
,
err
:=
strconv
.
Atoi
(
configs
[
5
])
if
err
==
nil
&&
checkFrequency
>
0
{
idleCheckFrequency
=
time
.
Duration
(
checkFrequency
)
*
time
.
Second
rp
.
idleCheckFrequency
=
time
.
Duration
(
checkFrequency
)
*
time
.
Second
}
}
var
maxRetries
=
0
if
len
(
configs
)
>
6
{
retries
,
err
:=
strconv
.
Atoi
(
configs
[
6
])
if
err
==
nil
&&
retries
>
0
{
maxRetries
=
retries
rp
.
maxRetries
=
retries
}
}
rp
.
poollist
=
rediss
.
NewClusterClient
(
&
rediss
.
ClusterOptions
{
Addrs
:
strings
.
Split
(
rp
.
savePath
,
";"
),
Password
:
rp
.
password
,
PoolSize
:
rp
.
poolsize
,
IdleTimeout
:
idleTimeout
,
IdleCheckFrequency
:
idleCheckFrequency
,
MaxRetries
:
maxRetries
,
Addrs
:
strings
.
Split
(
rp
.
savePath
,
";"
),
Password
:
rp
.
password
,
PoolSize
:
rp
.
poolsize
,
IdleTimeout
:
rp
.
idleTimeout
,
IdleCheckFrequency
:
rp
.
idleCheckFrequency
,
MaxRetries
:
rp
.
maxRetries
,
})
return
rp
.
poollist
.
Ping
()
.
Err
()
}
...
...
pkg/session/redis_sentinel/sess_redis_sentinel.go
浏览文件 @
7267f5e5
...
...
@@ -107,13 +107,16 @@ func (rs *SessionStore) SessionRelease(w http.ResponseWriter) {
// Provider redis_sentinel session provider
type
Provider
struct
{
maxlifetime
int64
savePath
string
poolsize
int
password
string
dbNum
int
poollist
*
redis
.
Client
masterName
string
maxlifetime
int64
savePath
string
poolsize
int
password
string
dbNum
int
idleTimeout
time
.
Duration
idleCheckFrequency
time
.
Duration
maxRetries
int
poollist
*
redis
.
Client
masterName
string
}
// SessionInit init redis_sentinel session
...
...
@@ -157,37 +160,34 @@ func (rp *Provider) SessionInit(maxlifetime int64, savePath string) error {
}
else
{
rp
.
masterName
=
"mymaster"
}
var
idleTimeout
time
.
Duration
=
0
if
len
(
configs
)
>
5
{
timeout
,
err
:=
strconv
.
Atoi
(
configs
[
4
])
if
err
==
nil
&&
timeout
>
0
{
idleTimeout
=
time
.
Duration
(
timeout
)
*
time
.
Second
rp
.
idleTimeout
=
time
.
Duration
(
timeout
)
*
time
.
Second
}
}
var
idleCheckFrequency
time
.
Duration
=
0
if
len
(
configs
)
>
6
{
checkFrequency
,
err
:=
strconv
.
Atoi
(
configs
[
5
])
if
err
==
nil
&&
checkFrequency
>
0
{
idleCheckFrequency
=
time
.
Duration
(
checkFrequency
)
*
time
.
Second
rp
.
idleCheckFrequency
=
time
.
Duration
(
checkFrequency
)
*
time
.
Second
}
}
var
maxRetries
=
0
if
len
(
configs
)
>
7
{
retries
,
err
:=
strconv
.
Atoi
(
configs
[
6
])
if
err
==
nil
&&
retries
>
0
{
maxRetries
=
retries
rp
.
maxRetries
=
retries
}
}
rp
.
poollist
=
redis
.
NewFailoverClient
(
&
redis
.
FailoverOptions
{
SentinelAddrs
:
strings
.
Split
(
rp
.
savePath
,
";"
),
Password
:
rp
.
password
,
PoolSize
:
rp
.
poolsize
,
DB
:
rp
.
dbNum
,
MasterName
:
rp
.
masterName
,
IdleTimeout
:
idleTimeout
,
IdleCheckFrequency
:
idleCheckFrequency
,
MaxRetries
:
maxRetries
,
SentinelAddrs
:
strings
.
Split
(
rp
.
savePath
,
";"
),
Password
:
rp
.
password
,
PoolSize
:
rp
.
poolsize
,
DB
:
rp
.
dbNum
,
MasterName
:
rp
.
masterName
,
IdleTimeout
:
rp
.
idleTimeout
,
IdleCheckFrequency
:
rp
.
idleCheckFrequency
,
MaxRetries
:
rp
.
maxRetries
,
})
return
rp
.
poollist
.
Ping
()
.
Err
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录