$persistenceInfo = $retriever->getPersistenceInfo();
// RDB (Snapshot) information
echo "RDB Last Save: " . $persistenceInfo->getRdbLastSaveTimeFormatted() . "\n";
echo "Changes Since Last Save: " . $persistenceInfo->getRdbChangesSinceLastSave() . "\n";
echo "Last Save Status: " . $persistenceInfo->getRdbLastBgsaveStatus() . "\n";
echo "RDB Save in Progress: " . ($persistenceInfo->isRdbSaveInProgress() ? 'Yes' : 'No') . "\n";
// AOF information
if ($persistenceInfo->isAofEnabled()) {
echo "\nAOF Enabled: Yes\n";
echo "AOF Current Size: " . number_format($persistenceInfo->getAofCurrentSize()) . " bytes\n";
echo "AOF Rewrite in Progress: " . ($persistenceInfo->isAofRewriteInProgress() ? 'Yes' : 'No') . "\n";
} else {
echo "\nAOF Enabled: No\n";
}
edisAnalizer\Service\RedisInformationRetriever;
$retriever = new RedisInformationRetriever();
$allInfo = $retriever->getAllInfo();
// Check memory fragmentation
if ($allInfo['memory']->isFragmented()) {
echo "[WARNING] High memory fragmentation detected: " .
$allInfo['memory']->getMemFragmentationRatio() . "\n";
}
// Check hit rate
$hitRate = $allInfo['stats']->getHitRate();
if ($hitRate < 80) {
echo "[WARNING] Low hit rate: {$hitRate}%\n";
echo "Consider reviewing your caching strategy.\n";
}
// Check client usage
$clientUsage = $allInfo['clients']->getClientUsagePercentage();
if ($clientUsage > 80) {
echo "[WARNING] High client usage: {$clientUsage}%\n";
echo "Current: {$allInfo['clients']->getConnectedClients()} / " .
"{$allInfo['clients']->getMaxclients()}\n";
}
// Check persistence status
if ($allInfo['persistence']->getRdbLastBgsaveStatus() !== 'ok') {
echo "[ERROR] Last RDB save failed!\n";
}
iever = new RedisAnalizer\Service\RedisInformationRetriever();
$allInfo = $retriever->getAllInfo();
$clientList = $retriever->getClientList();
// Use the data in your application
// $allInfo contains all Redis information
// $clientList contains detailed client information
namespace RedisAnalizer\Service;
use Predis\Client;
class RedisConnection
{
private static ?RedisConnection $redisConnection = null;
private function __construct(
string $server = 'localhost', // Change default host
int $port = 6379, // Change default port
string $connectionIdentifier = 'redis-analyzer-predis01',
bool $isPersistent = true
) {
// Connection configuration
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.