实现文档缓存

This commit is contained in:
Minho
2018-02-27 17:20:42 +08:00
parent 405a9c309f
commit 849058ff8a
6 changed files with 323 additions and 38 deletions

46
cache/cache.go vendored Normal file
View File

@@ -0,0 +1,46 @@
package cache
import (
"github.com/astaxie/beego/cache"
"time"
)
var bm cache.Cache
func Get(key string) interface{} {
return bm.Get(key)
}
func GetMulti(keys []string) []interface{} {
return bm.GetMulti(keys)
}
func Put(key string, val interface{}, timeout time.Duration) error {
return bm.Put(key, val, timeout)
}
func Delete(key string) error {
return bm.Delete(key)
}
func Incr(key string) error {
return bm.Incr(key)
}
func Decr(key string) error {
return bm.Decr(key)
}
func IsExist(key string) bool {
return bm.IsExist(key)
}
func ClearAll() error{
return bm.ClearAll()
}
func StartAndGC(config string) error {
return bm.StartAndGC(config)
}
//初始化缓存
func Init(c cache.Cache) {
bm = c
}