MilisPerSecDuration
This commit is contained in:
parent
23b020ec9b
commit
4eeace28f9
4 changed files with 5 additions and 5 deletions
|
@ -33,8 +33,8 @@ func ProviderNames() []string {
|
|||
}
|
||||
|
||||
// MilisPerSec return time resolution (milliseconds / 1sec) changed for short time in testing
|
||||
func MilisPerSec() int64 {
|
||||
return milis
|
||||
func MilisPerSecDuration() time.Duration {
|
||||
return time.Duration(milis)
|
||||
}
|
||||
|
||||
// Provider interace implement lifecycle for one session
|
||||
|
|
|
@ -155,7 +155,7 @@ func (pder *ProviderFiles) GC(maxlifetime int64) {
|
|||
if at, err = pder.getAtime(sid); err != nil {
|
||||
continue
|
||||
}
|
||||
if at.UnixMilli()+(maxlifetime*session.MilisPerSec()) < time.Now().UnixMilli() {
|
||||
if at.UnixMilli()+(maxlifetime*int64(session.MilisPerSecDuration())) < time.Now().UnixMilli() {
|
||||
log.Printf("GC remove session: %s atime: %v now: %v", sid, at, time.Now())
|
||||
pder.li.Remove(ssel)
|
||||
delete(pder.sessions, sid)
|
||||
|
|
|
@ -100,7 +100,7 @@ func (pder *ProviderMemory) GC(maxlifetime int64) {
|
|||
if ssel == nil {
|
||||
break
|
||||
}
|
||||
if ssel.Value.(*SessionMemory).atime.UnixMilli()+(maxlifetime*session.MilisPerSec()) < time.Now().UnixMilli() {
|
||||
if ssel.Value.(*SessionMemory).atime.UnixMilli()+(maxlifetime*int64(session.MilisPerSecDuration())) < time.Now().UnixMilli() {
|
||||
pder.li.Remove(ssel)
|
||||
delete(pder.sessions, ssel.Value.(*SessionMemory).sid)
|
||||
} else {
|
||||
|
|
|
@ -181,7 +181,7 @@ func (ts *TestServer) sessionGC(w http.ResponseWriter, r *http.Request) {
|
|||
io.WriteString(w, err.Error())
|
||||
return
|
||||
}
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
time.Sleep(200 * time.Millisecond * time.Duration(session.MilisPerSecDuration()))
|
||||
if sm.Exists(ses.SessionID()) {
|
||||
io.WriteString(w, fmt.Sprintf("Session id: %s must not exists in storage after GC",
|
||||
ses.SessionID()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue