Skip to content

Commit ec99cb4

Browse files
committed
fix
1 parent 6b85a1b commit ec99cb4

File tree

4 files changed

+20
-74
lines changed

4 files changed

+20
-74
lines changed

args_parser.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ func (e *EnvParse) Parse(env *ReqEnv, typ reflect.Type) (vl reflect.Value, parse
2424
}
2525

2626
//解析名称符合`*Args`的结构体
27-
2827
type ArgsParse struct{}
2928

3029
func (d *ArgsParse) Parse(env *ReqEnv, typ reflect.Type) (vl reflect.Value, parsed bool) {

handlerRegister.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ type tgw struct {
3131
index string
3232
}
3333

34+
func func_name() {
35+
36+
}
37+
3438
func NewTGW() *tgw {
3539
mux := http.NewServeMux()
3640
t := tgw{mux: mux, index: "/index"}
@@ -53,7 +57,7 @@ func (t *tgw) SetIndexPage(prefix string) *tgw {
5357
return t
5458
}
5559

56-
// 设置Session的存储介质,内置两种:应用程序空间内存及memecached
60+
// 设置Session的存储介质,内置memecached
5761
func (t *tgw) SetSessionStore(store SessionStoreInterface) *tgw {
5862
t.sessionStore = store
5963
return t

memcachedStoreSession.go

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package tgw
22

33
import (
4+
"github.com/icattlecoder/mcClient"
45
"encoding/json"
56
"errors"
67
"github.com/bradfitz/gomemcache/memcache"
78
)
89

910
//==================================================
1011
type memcachedSessionStore struct {
11-
client *memcache.Client
12+
client mcClient.MC
1213
}
1314

1415
func NewMemcachedSessionStore(mc ...string) *memcachedSessionStore {
15-
16-
return &memcachedSessionStore{client: memcache.New(mc...)}
16+
return &memcachedSessionStore{client:mcClient.NewGobMCClient("session", mc...)}
1717
}
1818

1919
func memcache_key(id, key string) string {
@@ -27,32 +27,22 @@ func (s *memcachedSessionStore) Clear(id string, key string) {
2727

2828
func (s *memcachedSessionStore) Get(id string, key string, val interface{}) (err error) {
2929

30-
item, err := s.client.Get(memcache_key(id, key))
31-
if err != nil {
32-
return
33-
}
34-
if len(item.Value) == 0 {
35-
err = errors.New("memcache miss cache,key:" + memcache_key(id, key))
36-
return
37-
}
38-
err = json.Unmarshal(item.Value, &val)
39-
if err != nil {
40-
return
41-
}
30+
err = s.client.Get(memcache_key(id, key),val)
31+
return
32+
}
33+
34+
func (s *memcachedSessionStore) GetString(id string, key string) (val string, err error) {
35+
36+
val, err = s.client.GetString(memcache_key(id, key))
4237
return
4338
}
4439

4540
func (s *memcachedSessionStore) Set(id string, key string, val interface{}) (err error) {
4641

47-
bval, err := json.Marshal(val)
48-
if err != nil {
49-
return
50-
}
42+
return s.client.Set(memcache_key(id, key), val)
43+
}
44+
45+
func (s *memcachedSessionStore) SetString(id string, key string, val string) (err error) {
5146

52-
item := &memcache.Item{
53-
Key: memcache_key(id, key),
54-
Value: bval,
55-
}
56-
err = s.client.Set(item)
57-
return
47+
return s.client.SetString(memcache_key(id,key), val)
5848
}

simpleStoreSession.go

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)