Skip to content

Commit

Permalink
Fixed# replace json with gob
Browse files Browse the repository at this point in the history
  • Loading branch information
Q1mi committed Jul 9, 2019
1 parent 7ef81f6 commit 5dc0a1b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ func (r *redisSession) Save() {
buf := new(bytes.Buffer)
enc := gob.NewEncoder(buf)
err := enc.Encode(r.data)
data, err := json.Marshal(r.data)
if err != nil {
log.Fatalf("gob encode r.data failed, err:%v\n", err)
return
}
r.client.Set(r.id, data, time.Second*time.Duration(r.expired))
log.Printf("set data: %v to redis.\n", data)
r.client.Set(r.id, buf.Bytes(), time.Second*time.Duration(r.expired))
log.Printf("set data: %v to redis.\n", buf.Bytes())
r.modifyFlag = false
}

Expand Down

0 comments on commit 5dc0a1b

Please sign in to comment.