|
|
@@ -106,6 +106,10 @@ class SaltController extends Controller
|
|
|
$ids = $db->createCommand("SELECT id FROM xhClear ORDER BY id DESC")->queryColumn();
|
|
|
$count = 0;
|
|
|
foreach ($ids as $id) {
|
|
|
+ // 支持 limit 参数限制更新数量
|
|
|
+ if ($this->limit > 0 && $count >= $this->limit) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
if ($this->dryRun) {
|
|
|
$this->stdout("[dry-run] xhClear id={$id}\n");
|
|
|
$count++;
|
|
|
@@ -117,6 +121,11 @@ class SaltController extends Controller
|
|
|
->bindValues([':salt' => $salt, ':id' => $id])
|
|
|
->execute();
|
|
|
$count++;
|
|
|
+
|
|
|
+ // 支持 sleepMs 降低数据库压力
|
|
|
+ if ($this->sleepMs > 0) {
|
|
|
+ usleep($this->sleepMs * 1000);
|
|
|
+ }
|
|
|
}
|
|
|
$this->stdout("xhClear salt 全部重新设置完成,共处理 {$count} 条记录\n");
|
|
|
return ExitCode::OK;
|
|
|
@@ -133,6 +142,10 @@ class SaltController extends Controller
|
|
|
$ids = $db->createCommand("SELECT id FROM xhSettle ORDER BY id DESC")->queryColumn();
|
|
|
$count = 0;
|
|
|
foreach ($ids as $id) {
|
|
|
+ // 支持 limit 参数限制更新数量
|
|
|
+ if ($this->limit > 0 && $count >= $this->limit) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
if ($this->dryRun) {
|
|
|
$this->stdout("[dry-run] xhSettle id={$id}\n");
|
|
|
$count++;
|
|
|
@@ -144,6 +157,11 @@ class SaltController extends Controller
|
|
|
->bindValues([':salt' => $salt, ':id' => $id])
|
|
|
->execute();
|
|
|
$count++;
|
|
|
+
|
|
|
+ // 支持 sleepMs 降低数据库压力
|
|
|
+ if ($this->sleepMs > 0) {
|
|
|
+ usleep($this->sleepMs * 1000);
|
|
|
+ }
|
|
|
}
|
|
|
$this->stdout("xhSettle salt 全部重新设置完成,共处理 {$count} 条记录\n");
|
|
|
return ExitCode::OK;
|