Procházet zdrojové kódy

add redis msg to common info

stanley-king před 7 roky
rodič
revize
ee90169e9e

+ 2 - 0
admin/control/cache.php

@@ -86,6 +86,7 @@ class cacheControl extends SystemControl
 
             // 删除商品相关数据
             $this->del_keys('goods*');
+            $this->mPublisher->modify_goods();
 
             // 删除手机红包相关缓存
             $this->del_keys('bonus*');
@@ -155,6 +156,7 @@ class cacheControl extends SystemControl
             // 删除商品相关数据
             if (in_array('goods',$todo)) {
                 $this->del_keys('goods*');
+                $this->mPublisher->modify_goods();
             }
 
             // 删除手机红包相关缓存

+ 10 - 2
helper/goods/commonid_helper.php

@@ -17,8 +17,6 @@ class commonid_helper
 
     private function __construct()
     {
-        $this->mGid2CidContainer = [];
-        $this->mMainImage = [];
     }
 
     static public function instance()
@@ -26,8 +24,18 @@ class commonid_helper
         if(self::$stInstance == null) {
             self::$stInstance = new commonid_helper();
         }
+        if(StatesHelper::fetch_state('common_info')) {
+            Log::record(__METHOD__ . " reinit.",Log::DEBUG);
+            self::$stInstance->init();
+        }
         return self::$stInstance;
     }
+    private function init()
+    {
+        $this->mGid2CidContainer = [];
+        $this->mCid2GidsContainer = [];
+        $this->mMainImage = [];
+    }
 
     public function main_image($goods_id)
     {

+ 7 - 0
helper/message/msgutil.php

@@ -30,6 +30,13 @@ class StatesHelper
             $states['fcode'] = true;
         }
     }
+    static public function onGoods($states,$msg)
+    {
+        $type = $msg['type'];
+        if($type == 'common_info') {
+            $states['common_info'] = true;
+        }
+    }
 
     static public function onActivity($states,$msg)
     {

+ 7 - 1
helper/message/publisher.php

@@ -52,7 +52,6 @@ class publisher
             $this->mRedis->publish('ch_index',serialize(array('type'=>'fcode','value' => 0)));
         }
     }
-    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function modify_index_special()
     {
         if($this->mConnected) {
@@ -60,6 +59,13 @@ class publisher
         }
     }
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    public function modify_goods()
+    {
+        if($this->mConnected) {
+            $this->mRedis->publish('goods',serialize(array('type'=>'common_info','value' => 0)));
+        }
+    }
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function modify_activity_fullsent()
     {
         if($this->mConnected) {

+ 7 - 0
helper/message/subscriber.php

@@ -91,6 +91,13 @@ class subscriber extends Thread
 
             return $ret;
         }
+        elseif($channel == 'goods') {
+            Mutex::lock($this->mLock);
+            $ret = StatesHelper::onGoods($this->mStates,$msg);
+            Mutex::unlock($this->mLock);
+
+            return $ret;
+        }
         else {
             return false;
         }