1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-25 21:11:29 +00:00

clear code

This commit is contained in:
lcbluestorm 2016-05-20 10:27:18 +08:00
parent 6234b50111
commit 4890dd708c
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package ssdb package ssdb
import ( import (
"errors"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
@ -21,6 +22,9 @@ type SsdbProvider struct {
func (p *SsdbProvider) connectInit() error { func (p *SsdbProvider) connectInit() error {
var err error var err error
if p.host == "" || p.port == 0 {
return errors.New("SessionInit First")
}
p.client, err = ssdb.Connect(p.host, p.port) p.client, err = ssdb.Connect(p.host, p.port)
if err != nil { if err != nil {
return err return err
@ -98,7 +102,6 @@ func (p *SsdbProvider) SessionRegenerate(oldsid, sid string) (session.Store, err
if value == nil || len(value.(string)) == 0 { if value == nil || len(value.(string)) == 0 {
kv = make(map[interface{}]interface{}) kv = make(map[interface{}]interface{})
} else { } else {
var err error
kv, err = session.DecodeGob([]byte(value.(string))) kv, err = session.DecodeGob([]byte(value.(string)))
if err != nil { if err != nil {
return nil, err return nil, err
@ -108,7 +111,7 @@ func (p *SsdbProvider) SessionRegenerate(oldsid, sid string) (session.Store, err
return nil, err return nil, err
} }
} }
_, e := p.client.Do("setx", sid, value.(string), p.maxLifetime) _, e := p.client.Do("setx", sid, value, p.maxLifetime)
if e != nil { if e != nil {
return nil, e return nil, e
} }

View File

@ -1,7 +1,6 @@
package ssdb package ssdb
import ( import (
"fmt"
"net/http" "net/http"
"testing" "testing"
) )
@ -55,6 +54,4 @@ func Test(t *testing.T) {
if p.SessionExist("1") { if p.SessionExist("1") {
t.Error("SessionExist err") t.Error("SessionExist err")
} }
fmt.Println(newS)
} }