Commit 6142da8a authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/optimize' into 'master'

fix See merge request !397
parents 8d2d9c84 dad76a08
...@@ -65,7 +65,7 @@ class IpExceptionController extends Controller ...@@ -65,7 +65,7 @@ class IpExceptionController extends Controller
return false; return false;
} }
$redis_ticker = \Yii::$app->redis_es; //$redis_ticker = \Yii::$app->redis_es;
$limit = \Yii::$app->params['api_ip_limit']['limit']; $limit = \Yii::$app->params['api_ip_limit']['limit'];
$white_list = \Yii::$app->params['api_ip_limit']['white_list']; $white_list = \Yii::$app->params['api_ip_limit']['white_list'];
$ips = ''; $ips = '';
...@@ -73,14 +73,17 @@ class IpExceptionController extends Controller ...@@ -73,14 +73,17 @@ class IpExceptionController extends Controller
if (in_array($val['key'], $white_list)) continue; if (in_array($val['key'], $white_list)) continue;
if (!isset($val['request']['buckets'])) continue; if (!isset($val['request']['buckets'])) continue;
foreach ($val['request']['buckets'] as $b => $item) { foreach ($val['request']['buckets'] as $b => $item) {
if (strpos($item['key'],'/interface/ticker/hot-ticker') !== false) { if ($item['doc_count'] > $limit) {
if ($item['doc_count'] > $limit) { $ips .= $val['key'] . ',';
foreach ($val['request']['buckets'] as $bucket) {
$redis_ticker->hmset($val['key'], $bucket['key'], $bucket['doc_count']);
}
$ips .= $val['key'] . ',';
}
} }
// if (strpos($item['key'],'/interface/ticker/hot-ticker') !== false) {
// if ($item['doc_count'] > $limit) {
// foreach ($val['request']['buckets'] as $bucket) {
// $redis_ticker->hmset($val['key'], $bucket['key'], $bucket['doc_count']);
// }
// $ips .= $val['key'] . ',';
// }
// }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment