mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 06:01:50 +00:00
First commit
This commit is contained in:
37
examples/guestbook/index.php
Normal file
37
examples/guestbook/index.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?
|
||||
|
||||
set_include_path('.:/usr/share/php:/usr/share/pear:/vendor/predis');
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
require 'predis/autoload.php';
|
||||
|
||||
if (isset($_GET['cmd']) === true) {
|
||||
header('Content-Type: application/json');
|
||||
if ($_GET['cmd'] == 'set') {
|
||||
$client = new Predis\Client([
|
||||
'scheme' => 'tcp',
|
||||
'host' => getenv('SERVICE_HOST'),
|
||||
'port' => getenv('REDISMASTER_SERVICE_PORT'),
|
||||
]);
|
||||
$client->set($_GET['key'], $_GET['value']);
|
||||
print('{"message": "Updated"}');
|
||||
} else {
|
||||
$read_port = getenv('REDISMASTER_SERVICE_PORT');
|
||||
|
||||
if (isset($_ENV['REDISSLAVE_SERVICE_PORT'])) {
|
||||
$read_port = getenv('REDISSLAVE_SERVICE_PORT');
|
||||
}
|
||||
$client = new Predis\Client([
|
||||
'scheme' => 'tcp',
|
||||
'host' => getenv('SERVICE_HOST'),
|
||||
'port' => $read_port,
|
||||
]);
|
||||
|
||||
$value = $client->get($_GET['key']);
|
||||
print('{"data": "' . $value . '"}');
|
||||
}
|
||||
} else {
|
||||
phpinfo();
|
||||
} ?>
|
Reference in New Issue
Block a user