/** * Execute the command. * * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $memcached = Connection::get($input->getOption('host'), $input->getOption('port')); if (!$memcached) { return $output->writeln('<error>Could not connect to memcached server!</error>'); } $stats = (object) array_values($memcached->getStats())[0]; $output->writeln('Memcached Server Stats'); $output->writeln('Version: <info>' . $stats->version . '</info>'); $output->writeln('Uptime: <info>' . timeAgoInWords(date('c', time() - $stats->uptime)) . '</info>'); $output->writeln('Items in cache: <info>' . $stats->curr_items . '</info>'); $output->writeln('Size of cache: <info>' . Units::bytes($stats->bytes)->format() . '</info>'); }
/** * Format bytes to a human readable size. * * @param int $bytes * * @return string */ public function formatBytes($bytes) { return \ByteUnits\Binary::bytes($bytes)->format(); }