-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmemcachedStoreSession.go
43 lines (29 loc) · 1.05 KB
/
memcachedStoreSession.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package tgw
import (
"github.com/icattlecoder/mcClient"
)
//==================================================
type memcachedSessionStore struct {
client mcClient.MC
}
func NewMemcachedSessionStore(mc ...string) *memcachedSessionStore {
return &memcachedSessionStore{client: mcClient.NewGobMCClient("session", mc...)}
}
func memcache_key(id, key string) string {
return id + key
}
func (s *memcachedSessionStore) Clear(id string, key string) {
s.client.Delete(memcache_key(id, key))
}
func (s *memcachedSessionStore) Get(id string, key string, val interface{}) (err error) {
return s.client.Get(memcache_key(id, key), val)
}
func (s *memcachedSessionStore) GetString(id string, key string) (val string, err error) {
return s.client.GetString(memcache_key(id, key))
}
func (s *memcachedSessionStore) Set(id string, key string, val interface{}) (err error) {
return s.client.Set(memcache_key(id, key), val)
}
func (s *memcachedSessionStore) SetString(id string, key string, val string) (err error) {
return s.client.SetString(memcache_key(id, key), val)
}