Files
EQN/appServer/test_redis.php
T
2017-09-22 15:16:26 +02:00

74 lines
1.5 KiB
PHP

<h1>Hello world!!!</h1>
Testing procedure Redis per EQN...
<?php
require "Predis/Autoloader.php";
#PredisAutoloader::register();
Predis\Autoloader::register();
try {
$redis = new Predis\Client();
// This connection is for a remote server
$redis = new Predis\Client(array(
"scheme" => "tcp",
"host" => "172.16.1.80",
#"host" => "redis01",
"port" => 6379
));
}
catch (Exception $e) {
die($e->getMessage());
}
?>
inizializzato!
<hr/>
<?php
$server = gethostname();
$adesso = date("F j, Y \a\t g:ia");
$redis->set($server,$adesso);
$redis->incr($server."_count");
$redis->hset("taxi_car", "brand", "Toyota");
$redis->hset("taxi_car", "model", "Yaris");
$redis->hset("taxi_car", "license number", "RO-01-PHP");
$redis->hset("taxi_car", "year of fabrication", 2010);
$redis->hset("taxi_car", "nr_starts", 0);
$valore = $redis->get($server);
echo ($redis->exists($server)) ? "Valore salvato: ".$valore : "Prego salvare valore...";
$taxi_car = $redis->hgetall("taxi_car");
echo "<hr/>";
echo "All info about taxi car";
echo "<pre>";
var_dump($taxi_car);
echo "</pre>";
echo "<hr/>";
$list = "PHP Frameworks List";
$redis->rpush($list, "Symfony 2");
$redis->rpush($list, "Symfony 1.4");
$redis->lpush($list, "Zend Framework");
echo "Number of frameworks in list: " . $redis->llen($list) . "<br>";
$arList = $redis->lrange($list, 0, -1);
echo "<pre>";
print_r($arList);
echo "</pre>";
// the last entry in the list
echo $redis->rpop($list) . "<br>";
// the first entry in the list
echo $redis->lpop($list) . "<br>";
?>