Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
d48b7e01
authored
2013-12-14 23:29:17 +0800
by
slene
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
#369 set maxlifetime, close conn
1 parent
495033b9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
session/sess_redis.go
session/sess_redis.go
View file @
d48b7e0
...
...
@@ -19,6 +19,7 @@ type RedisSessionStore struct {
sid
string
lock
sync
.
RWMutex
values
map
[
interface
{}]
interface
{}
maxlifetime
int64
}
func
(
rs
*
RedisSessionStore
)
Set
(
key
,
value
interface
{})
error
{
...
...
@@ -65,6 +66,7 @@ func (rs *RedisSessionStore) SessionRelease() {
return
}
rs
.
c
.
Do
(
"SET"
,
rs
.
sid
,
string
(
b
))
rs
.
c
.
Do
(
"EXPIRE"
,
rs
.
sid
,
rs
.
maxlifetime
)
}
}
...
...
@@ -129,12 +131,13 @@ func (rp *RedisProvider) SessionRead(sid string) (SessionStore, error) {
return
nil
,
err
}
}
rs
:=
&
RedisSessionStore
{
c
:
c
,
sid
:
sid
,
values
:
kv
}
rs
:=
&
RedisSessionStore
{
c
:
c
,
sid
:
sid
,
values
:
kv
,
maxlifetime
:
rp
.
maxlifetime
}
return
rs
,
nil
}
func
(
rp
*
RedisProvider
)
SessionExist
(
sid
string
)
bool
{
c
:=
rp
.
poollist
.
Get
()
defer
c
.
Close
()
if
existed
,
err
:=
redis
.
Int
(
c
.
Do
(
"EXISTS"
,
sid
));
err
!=
nil
||
existed
==
0
{
return
false
}
else
{
...
...
@@ -159,12 +162,13 @@ func (rp *RedisProvider) SessionRegenerate(oldsid, sid string) (SessionStore, er
return
nil
,
err
}
}
rs
:=
&
RedisSessionStore
{
c
:
c
,
sid
:
sid
,
values
:
kv
}
rs
:=
&
RedisSessionStore
{
c
:
c
,
sid
:
sid
,
values
:
kv
,
maxlifetime
:
rp
.
maxlifetime
}
return
rs
,
nil
}
func
(
rp
*
RedisProvider
)
SessionDestroy
(
sid
string
)
error
{
c
:=
rp
.
poollist
.
Get
()
defer
c
.
Close
()
c
.
Do
(
"DEL"
,
sid
)
return
nil
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment