| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- package cache
- import (
- "fmt"
- "github.com/astaxie/beego/cache"
- )
- const (
- DEL = "del"
- GET = "get"
- )
- var Cache cache.Cache
- func init() {
- var err error
- Cache, err = cache.NewCache("memory", `{"interval":60}`)
- if err != nil {
- panic(err)
- }
- }
- const (
- //根据公众号openid查询用户公众号
- GetWxUserGzhByOpenId = "user_model.GetWxUserGzhByOpenId"
- //根据微信用户id查询用户公众号
- GetWxUserGzhByWxUId = "user_model.GetWxUserGzhByWxUId"
- //根据微信用户id和appid查询用户公众号
- GetWxUserGzhByWxUIdAndAppId = "user_model.GetWxUserGzhByWxUIdAndAppId"
- //项目当前融资总额
- ProjectCurrentInvestment = "project_join_model.CurrentInvestment"
- //项目当前融资总额-我想认购
- ProjectCurrentExpectInvestment = "project_join_model.CurrentExpectInvestment"
- //项目关注人数
- ProjectFollowCount = "project_model.GetFollowersCountByPId"
- //项目投资人列表
- ProjectInvestors = "project_join_model.GetInvestorsByPId"
- //我想认购-投资人列表
- ProjectExpectInvestors = "project_join_model.GetExpectInvestorsByPId"
- //抽奖活动-已开奖的奖品数量
- OpenedAwardCount = "lottery_model.GetOpenedProductCount"
- //翻红包专题-合体次数
- FHBSuccessCount = "zt_model.GetFHBSuccessCount"
- //翻红包专题-红包记录
- FHBRecordById = "zt_model.GetFHBRecordById"
- //翻红包专题-合体成功列表
- FHBSuccessRecordsByWxUId = "zt_model.GetFHBSuccessRecordsByWxUId"
- //
- GetWxUserById = "user_model.GetWxUserById"
- GetThreeWxUserById = "user_model.GetThreeWxUserById"
- //商品
- GetProductPackagetByPId = "product_model.GetPackageList"
- GetProductByPId = "product_model.GetProductById"
- GetProductByPIdAndProvince = "product_model.GetProductByPIdAndProvince"
- //项目
- GetProjectById = "project_model.GetProjectById"
- //默认签章
- GetDefaultSealByUId = "tsign_model.GetDefaultSealByUId"
- // 根据uId,pId查询个人摘要签
- GetAllUserFileSignByPIdAndUId = "tsign_model.GetAllUserFileSignByPIdAndUId"
- // 根据uId查询个人摘要签
- GetAllUserFileSignByUId = "tsign_model.GetAllUserFileSignByUId"
- //文章详情分享送佣金
- ArticleDetailOpenBenefitByAId = "article_model.ArticleDetailOpenBenefitByAId"
- // 根据活动ID,获取活动信息
- GetActivityById = "kj_model.GetActivityById"
- //自动登录Key
- WapAutoLoginKey = "permit_controller.WapAutoLoginKey"
- )
- func GetKey(key string, params ...interface{}) string {
- cacheKey := ""
- switch key {
- case GetWxUserGzhByWxUIdAndAppId:
- cacheKey = fmt.Sprintf("%s.wxUid(%d).appId(%s)", key, params[0], params[1])
- case GetWxUserGzhByWxUId:
- cacheKey = fmt.Sprintf("%s.wxUid(%d)", key, params[0])
- case GetWxUserGzhByOpenId:
- cacheKey = fmt.Sprintf("%s.openId(%s)", key, params[0])
- case GetProjectById:
- cacheKey = fmt.Sprintf("%s.pId(%d)", key, params[0])
- case ProjectCurrentInvestment:
- cacheKey = fmt.Sprintf("%s.pId(%d)", key, params[0])
- case ProjectCurrentExpectInvestment:
- cacheKey = fmt.Sprintf("%s.pId(%d)", key, params[0])
- case ProjectFollowCount:
- cacheKey = fmt.Sprintf("%s.pId(%d)", key, params[0])
- case ProjectInvestors:
- cacheKey = fmt.Sprintf("%s.pId(%d).page(%d).perPage(%d)", key, params[0], params[1], params[2])
- case ProjectExpectInvestors:
- cacheKey = fmt.Sprintf("%s.pId(%d).page(%d).perPage(%d)", key, params[0], params[1], params[2])
- case OpenedAwardCount:
- cacheKey = fmt.Sprintf("%s.actId(%d).proId(%d)", key, params[0], params[1])
- case FHBSuccessCount:
- cacheKey = fmt.Sprintf("%s.wxUId(%d).cId(%d).date(%s)", key, params[0], params[1], params[2])
- case FHBRecordById:
- cacheKey = fmt.Sprintf("%s.id(%d)", key, params[0])
- case GetWxUserById:
- cacheKey = fmt.Sprintf("%s.id(%d)", key, params[0])
- case FHBSuccessRecordsByWxUId:
- cacheKey = fmt.Sprintf("%s.uId(%d).cId(%d)", key, params[0], params[1])
- case GetDefaultSealByUId:
- cacheKey = fmt.Sprintf("%s.uId(%d)", key, params[0])
- case GetAllUserFileSignByPIdAndUId:
- cacheKey = fmt.Sprintf("%s.uId(%d).pId(%d)", key, params[0], params[1])
- case GetAllUserFileSignByUId:
- cacheKey = fmt.Sprintf("%s.uId(%d)", key, params[0])
- case ArticleDetailOpenBenefitByAId:
- cacheKey = fmt.Sprintf("%s.aId(%d).wxUId(%d).oTime(%d)", key, params[0], params[1], params[2])
- case GetActivityById:
- cacheKey = fmt.Sprintf("%s_%d", key, params[0])
- case WapAutoLoginKey:
- cacheKey = fmt.Sprintf("%s.uId(%d)", key, params[0])
- case GetProductPackagetByPId:
- cacheKey = fmt.Sprintf("%s.pId(%d)", key, params[0])
- case GetProductByPId:
- cacheKey = fmt.Sprintf("%s.pId(%d)", key, params[0])
- case GetProductByPIdAndProvince:
- cacheKey = fmt.Sprintf("%s.pId(%d)prv(%s)", key, params[0], params[1])
- }
- return cacheKey
- }
- // func DelKey(key string, params ...interface{}) string {
- // cacheKey := ""
- // switch key {
- // case ProjectCurrentInvestment:
- // cacheKey = fmt.Sprintf("%s.pId(%d)", key, params[0])
- // case ProjectFollowCount:
- // cacheKey = fmt.Sprintf("%s.pId(%d)", key, params[0])
- // case ProjectInvestors:
- // cacheKey = fmt.Sprintf("%s.pId(%d).page(%d).perPage(%d)", key, params[0], params[1], params[2])
- // case OpenedAwardCount:
- // cacheKey = fmt.Sprintf("%s.actId(%d).proId(%d)", key, params[0], params[1])
- // case FHBSuccessCount:
- // cacheKey = fmt.Sprintf("%s.wxUId(%d).cId(%d).date(%s)", key, params[0], params[1], params[2])
- // case FHBRecordById:
- // cacheKey = fmt.Sprintf("%s.id(%d)", key, params[0])
- // case GetWxUserById:
- // cacheKey = fmt.Sprintf("%s.id(%d)", key, params[0])
- // }
- // cache.Cache.Delete(cacheKey)
- // }
|