diff --git a/app/init.go b/app/init.go index e18ac83..c295907 100644 --- a/app/init.go +++ b/app/init.go @@ -10,8 +10,6 @@ import ( "github.com/leanote/leanote/app/controllers/admin" "github.com/leanote/leanote/app/controllers/member" _ "github.com/leanote/leanote/app/lea/binder" -// "github.com/leanote/leanote/app/lea/session" -// "github.com/leanote/leanote/app/lea/memcache" "github.com/leanote/leanote/app/lea/route" "reflect" "fmt" diff --git a/app/lea/memcache/Memcache.go b/app/lea/memcache/Memcache.go deleted file mode 100644 index 23ab0d5..0000000 --- a/app/lea/memcache/Memcache.go +++ /dev/null @@ -1,66 +0,0 @@ -package memcache - -import ( - "github.com/robfig/gomemcache/memcache" - "encoding/json" - "strconv" -) - -var client *memcache.Client - -// onAppStart后调用 -func InitMemcache() { - client = memcache.New("localhost:11211") -} - -//------------ -// map - -func SetMap(key string, value map[string]string, expiration int32) { - // 把value转成byte - bytes, _ := json.Marshal(value) - if expiration == -1 { - expiration = 30 * 24 * 60 * 60 // 30天 - } - client.Set(&memcache.Item{Key: key, Value: bytes, Expiration: expiration}) -} - -func GetMap(key string) map[string]string { - item, err := client.Get(key) - if err != nil { - return nil - } - - m := map[string]string{} - json.Unmarshal(item.Value, &m) - return m -} - -//------------ -// string -func GetString(key string) string { - item, err := client.Get(key) - if err != nil { - return "" - } - return string(item.Value) -} -func SetString(key string, value string, expiration int32) { - if expiration == -1 { - expiration = 30 * 24 * 60 * 60 // 30天 - } - client.Set(&memcache.Item{Key: key, Value: []byte(value), Expiration: expiration}) -} - -//------------------------- -// int, 是通过转成string来存的 - -func GetInt(key string) int { - str := GetString(key) - i, _ := strconv.Atoi(str) - return i -} -func SetInt(key string, value int, expiration int32) { - str := strconv.Itoa(value) - SetString(key, str, expiration) -}