package cache import "fmt" func GetCache(myId string) (interface{}, bool) { return myCache.getCache(myId) } func SetCache(myId string, myVal interface{}) { myCache.setCache(myId, myVal) } func SetCacheTimeout(myId string, myVal interface{}, timeout int64) { myCache.setCacheTimeout(myId, myVal, timeout) } func DelCache(myId string) { myCache.delCache(myId) } func SetToken(userId int, token string) { myCache.setCache(fmt.Sprintf("token_%d", userId), token) } func GetToken(userId int) string { cacheId := fmt.Sprintf("token_%d", userId) if val, flag := myCache.getCache(cacheId); flag { return val.(string) } return "" } func SetPayOk(outTradeBo string) { myCache.setCache(fmt.Sprintf("pay_%s", outTradeBo), true) } func IsPayOk(outTradeBo string) bool { if _, flag := myCache.getCache(fmt.Sprintf("pay_%s", outTradeBo)); flag { return true } return false } func SetPhoneCode(phone, code string) { myCache.setCacheTimeout(fmt.Sprintf("phone_%s", phone), code, 300) } func GetPhoneCode(phone string) string { cacheId := fmt.Sprintf("phone_%s", phone) if val, flag := myCache.getCache(cacheId); flag { return val.(string) } return "637901" }