Untitled
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use Throwable; use Predis\Client as RedisClient; class DragonflyTestCommand extends Command { protected $signature = 'test:dragonfly'; protected $description = 'Test Dragonfly by loading 3 GB of data and restarting the container'; /** * @return void * @throws Throwable */ public function handle(): void { $redis = new RedisClient([ 'scheme' => 'tcp', 'host' => '127.0.0.1', 'port' => 6379, ]); try { $this->info('Loading 3 GB of data into Dragonfly...'); $dataChunk = str_repeat('x', 1024 * 1024); // 1 MB for ($i = 0; $i < 3000; $i++) { $redis->set("key:$i", $dataChunk); } $this->info('Data loaded successfully!'); } catch (Throwable $e) { $this->error('An error occurred: ' . $e->getMessage()); } } }
Leave a Comment