cache.go 332 B

12345678910111213141516171819
  1. package config
  2. import (
  3. "encoding/json"
  4. "gadmin/utility/character"
  5. "github.com/patrickmn/go-cache"
  6. "time"
  7. )
  8. var Cache *cache.Cache
  9. func InitCache() {
  10. Cache = cache.New(10*time.Minute, 15*time.Minute)
  11. }
  12. func UKey(label string, v interface{}) string {
  13. b, _ := json.Marshal(v)
  14. return label + ":" + character.Md5Content(b)
  15. }