tongshanglei 2 jaren geleden
bovenliggende
commit
fdb0e3311b
2 gewijzigde bestanden met toevoegingen van 17 en 2 verwijderingen
  1. 16 1
      app/common.php
  2. 1 1
      catch/yunying/controller/Vehicle.php

+ 16 - 1
app/common.php

@@ -6,7 +6,7 @@ use Aliyun\OTS\Consts\OperationTypeConst;
 use Aliyun\OTS\Consts\PrimaryKeyTypeConst;
 use Aliyun\OTS\Consts\RowExistenceExpectationConst;
 use Aliyun\OTS\OTSClient;
-
+use think\facade\Cache;
     /**
      * 查询Gps股轨迹 表格存储
      */
@@ -1389,6 +1389,16 @@ use Aliyun\OTS\OTSClient;
             trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
         }
         $whereStr=buildQueryCond($cond);
+
+        $redis=Cache::store('redis')->handler();
+        $redis_info= $redis->hget('vehicle_table_count', $whereStr);
+        if($redis_info){
+            $info=json_decode($redis_info,true);
+            if((time()-$info['time'])<24*3600){
+                return $info['count'];
+            }
+        }
+      
         $countQuery='SELECT count(*) as count FROM  '.$tableName.' '.$whereStr;
         // var_dump($countQuery);
         // return 0;
@@ -1403,6 +1413,11 @@ use Aliyun\OTS\OTSClient;
         // var_dump($rows);
         oci_free_statement($stid);
         oci_close($conn);
+        $rds_info=[
+            'count'=>(int)$rows[0]['COUNT'],
+            'time'=>time(),
+        ];
+        $res=$redis->hset('vehicle_table_count', $whereStr,json_encode($rds_info));
         return (int)$rows[0]['COUNT'];
     }
     

+ 1 - 1
catch/yunying/controller/Vehicle.php

@@ -51,7 +51,7 @@ class Vehicle extends CatchController
 
         // $count=queryOracleCount('DSSC3.W_DW_NON_MOTOR o,DSSC3.W_DW_NON_MOTOR_OWNER r,DSSC3.W_DW_RFID_TAGS s',$cond);
         $count=queryOracleCount('DSSC3.W_DW_NON_MOTOR o,DSSC3.W_DW_RFID_TAGS s',$cond);
-
+        // $count=100000;
         $cond['page']=isset($param['page'])?$param['page']:1;
         $cond['limit']=isset($param['limit'])?$param['limit']:10;
         // $rows=queryOracleSelect('DSSC3.W_DW_NON_MOTOR o,DSSC3.W_DW_NON_MOTOR_OWNER r,DSSC3.W_DW_RFID_TAGS s',$cond,'o.PLATE_NO,s.RFID_SN,r. NAME,r.ID_CARD_NUMBER,r.MOBILE_NUMBER,r.HOME_ADDRESS');