Skip to content

Commit

Permalink
use json-iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
LyricTian committed Apr 26, 2018
1 parent f5c9f64 commit 3013a23
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ package session

import (
"context"
"encoding/json"
"sync"
"time"

"github.com/json-iterator/go"
"github.com/tidwall/buntdb"
)

var (
_ ManagerStore = &defaultManagerStore{}
_ Store = &defaultStore{}
_ ManagerStore = &defaultManagerStore{}
_ Store = &defaultStore{}
jsonMarshal = jsoniter.Marshal
jsonUnmarshal = jsoniter.Unmarshal
)

// ManagerStore Management of session storage, including creation, update, and delete operations
Expand Down Expand Up @@ -92,7 +94,7 @@ func (s *defaultManagerStore) parseValue(value string) (map[string]string, error
var values map[string]string

if len(value) > 0 {
err := json.Unmarshal([]byte(value), &values)
err := jsonUnmarshal([]byte(value), &values)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -217,7 +219,7 @@ func (s *defaultStore) Save() error {

s.RLock()
if len(s.values) > 0 {
buf, _ := json.Marshal(s.values)
buf, _ := jsonMarshal(s.values)
value = string(buf)
}
s.RUnlock()
Expand Down

0 comments on commit 3013a23

Please sign in to comment.