1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace App\Console\Commands\Cache;
- use App\Models\User\UserModel;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Redis;
- class MapCommand extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'cache:map';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '地图数据缓存';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $data = [
- 'province_count' => '34',
- 'city_count' => '301',
- 'school_count' => '1845'
- ];
- $data['card_count'] = UserModel::where('sex', 0)->count();
- $data['men_count'] = UserModel::where('sex', 1)->count();
- $data['women_count'] = UserModel::where('sex', 2)->count();
- Redis::set('map', json_encode($data));
- }
- }
|