Bladeren bron

product package item develop---clearn system package cache

abiao 4 jaren geleden
bovenliggende
commit
882173db11

+ 8 - 3
go/gopath/src/fohow.com/apps/controllers/railsadmin_controller/cache_controller.go

@@ -1,10 +1,10 @@
 package railsadmin_controller
 
 import (
-	"github.com/astaxie/beego"
-	"github.com/astaxie/beego/context"
 	"fohow.com/apps"
 	"fohow.com/cache"
+	"github.com/astaxie/beego"
+	"github.com/astaxie/beego/context"
 	"strconv"
 )
 
@@ -31,10 +31,15 @@ func (self *RailsadminController) CleanCache() {
 	id, _ := strconv.ParseInt(_id, 10, 64)
 	beego.BeeLogger.Warn("t: %s, id: %d", t, id)
 
-	if t == "project" {
+	switch {
+	case t == "project":
 		beego.BeeLogger.Warn("railsadmin after update clean cache: %d", id)
 		k := cache.GetKey(cache.GetProjectById, id)
 		cache.Cache.Delete(k)
+	case t == "package":
+		beego.BeeLogger.Warn("railsadmin after save clean cache: %d", id)
+		k := cache.GetKey(cache.GetProductPackagetByPId, id)
+		cache.Cache.Delete(k)
 	}
 	self.ServeJSON()
 }

+ 2 - 2
go/gopath/src/fohow.com/apps/models/product_model/product_item.go

@@ -1,7 +1,6 @@
 package product_model
 
 import (
-	"fmt"
 	"fohow.com/cache"
 	"github.com/astaxie/beego"
 	"github.com/astaxie/beego/orm"
@@ -29,7 +28,8 @@ func (self *ProductItem) TableName() string {
 
 // 根据商品Id找出商品对应套装明细
 func GetPackageList(pId int64, useCache bool) (items []*ProductItem) {
-	k := fmt.Sprintf("product_model.GetPackageList(%d)", pId)
+	//k := fmt.Sprintf("product_model.GetPackageList(%d)", pId)
+	k := cache.GetKey(cache.GetProductPackagetByPId, pId)
 	if useCache {
 		if ret, ok := cache.Cache.Get(k).([]*ProductItem); ok {
 			return ret

+ 5 - 0
go/gopath/src/fohow.com/cache/init.go

@@ -51,6 +51,8 @@ const (
 	GetWxUserById      = "user_model.GetWxUserById"
 	GetThreeWxUserById = "user_model.GetThreeWxUserById"
 
+	//商品
+	GetProductPackagetByPId = "product_model.GetPackageList"
 	//项目
 	GetProjectById = "project_model.GetProjectById"
 	//默认签章
@@ -110,6 +112,9 @@ func GetKey(key string, params ...interface{}) string {
 		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])
+
 	}
 
 	return cacheKey