mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
实现文档缓存
This commit is contained in:
46
cache/cache.go
vendored
Normal file
46
cache/cache.go
vendored
Normal 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
|
||||
}
|
||||
39
cache/cache_null.go
vendored
Normal file
39
cache/cache_null.go
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package cache
|
||||
|
||||
import "time"
|
||||
|
||||
type NullCache struct {
|
||||
|
||||
}
|
||||
|
||||
|
||||
func (bm *NullCache)Get(key string) interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bm *NullCache)GetMulti(keys []string) []interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bm *NullCache)Put(key string, val interface{}, timeout time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
func (bm *NullCache)Delete(key string) error {
|
||||
return nil
|
||||
}
|
||||
func (bm *NullCache)Incr(key string) error {
|
||||
return nil
|
||||
}
|
||||
func (bm *NullCache)Decr(key string) error {
|
||||
return nil
|
||||
}
|
||||
func (bm *NullCache)IsExist(key string) bool {
|
||||
return false
|
||||
}
|
||||
func (bm *NullCache)ClearAll() error{
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bm *NullCache)StartAndGC(config string) error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user