mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
40 lines
895 B
PHP
40 lines
895 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Console\Commands;
|
||
|
|
|
||
|
|
use App\Repositories\TorrentRepository;
|
||
|
|
use Illuminate\Console\Command;
|
||
|
|
|
||
|
|
class TorrentLoadPiecesHash extends Command
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* The name and signature of the console command.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $signature = 'torrent:load_pieces_hash {--id=}';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* The console command description.
|
||
|
|
*
|
||
|
|
* @var string
|
||
|
|
*/
|
||
|
|
protected $description = 'Load torrent pieces hash to cache';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Execute the console command.
|
||
|
|
*
|
||
|
|
* @return int
|
||
|
|
*/
|
||
|
|
public function handle()
|
||
|
|
{
|
||
|
|
$begin = time();
|
||
|
|
$id = $this->option('id');
|
||
|
|
$rep = new TorrentRepository();
|
||
|
|
$this->info("id: $id");
|
||
|
|
$total = $rep->loadPiecesHashCache($id);
|
||
|
|
$this->info(sprintf("total: %s, cost time: %s seconds.", $total, time() - $begin));
|
||
|
|
return Command::SUCCESS;
|
||
|
|
}
|
||
|
|
}
|