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
a58c8180
Commit
a58c8180
authored
Jun 07, 2015
by
weizili.laptop
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Execute AUTH command when the "password" is configured
parent
af71289c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
redis.go
cache/redis/redis.go
+17
-1
No files found.
cache/redis/redis.go
View file @
a58c8180
...
...
@@ -51,6 +51,7 @@ type RedisCache struct {
conninfo
string
dbNum
int
key
string
password
string
}
// create new redis cache with default collection name.
...
...
@@ -149,16 +150,20 @@ func (rc *RedisCache) StartAndGC(config string) error {
if
_
,
ok
:=
cf
[
"key"
];
!
ok
{
cf
[
"key"
]
=
DefaultKey
}
if
_
,
ok
:=
cf
[
"conn"
];
!
ok
{
return
errors
.
New
(
"config has no conn key"
)
}
if
_
,
ok
:=
cf
[
"dbNum"
];
!
ok
{
cf
[
"dbNum"
]
=
"0"
}
if
_
,
ok
:=
cf
[
"password"
];
!
ok
{
cf
[
"password"
]
=
""
}
rc
.
key
=
cf
[
"key"
]
rc
.
conninfo
=
cf
[
"conn"
]
rc
.
dbNum
,
_
=
strconv
.
Atoi
(
cf
[
"dbNum"
])
rc
.
password
=
cf
[
"password"
]
rc
.
connectInit
()
c
:=
rc
.
p
.
Get
()
...
...
@@ -171,6 +176,17 @@ func (rc *RedisCache) StartAndGC(config string) error {
func
(
rc
*
RedisCache
)
connectInit
()
{
dialFunc
:=
func
()
(
c
redis
.
Conn
,
err
error
)
{
c
,
err
=
redis
.
Dial
(
"tcp"
,
rc
.
conninfo
)
if
err
!=
nil
{
return
nil
,
err
}
if
rc
.
password
!=
""
{
if
_
,
err
:=
c
.
Do
(
"AUTH"
,
rc
.
password
);
err
!=
nil
{
c
.
Close
()
return
nil
,
err
}
}
_
,
selecterr
:=
c
.
Do
(
"SELECT"
,
rc
.
dbNum
)
if
selecterr
!=
nil
{
c
.
Close
()
...
...
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