cache.go 724 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package cache
  2. import (
  3. "github.com/astaxie/beego/cache"
  4. "time"
  5. )
  6. var bm cache.Cache
  7. func Get(key string) interface{} {
  8. return bm.Get(key)
  9. }
  10. func GetMulti(keys []string) []interface{} {
  11. return bm.GetMulti(keys)
  12. }
  13. func Put(key string, val interface{}, timeout time.Duration) error {
  14. return bm.Put(key, val, timeout)
  15. }
  16. func Delete(key string) error {
  17. return bm.Delete(key)
  18. }
  19. func Incr(key string) error {
  20. return bm.Incr(key)
  21. }
  22. func Decr(key string) error {
  23. return bm.Decr(key)
  24. }
  25. func IsExist(key string) bool {
  26. return bm.IsExist(key)
  27. }
  28. func ClearAll() error{
  29. return bm.ClearAll()
  30. }
  31. func StartAndGC(config string) error {
  32. return bm.StartAndGC(config)
  33. }
  34. //初始化缓存
  35. func Init(c cache.Cache) {
  36. bm = c
  37. }