mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
Use GCR images from 'google-samples' project; allow switch on whether dns service is
supported, or to use env vars to get service host info. Test change to reflect php filename change.
This commit is contained in:
43
examples/guestbook/php-redis/guestbook.php
Normal file
43
examples/guestbook/php-redis/guestbook.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?
|
||||
|
||||
set_include_path('.:/usr/local/lib/php');
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
require 'Predis/Autoloader.php';
|
||||
|
||||
Predis\Autoloader::register();
|
||||
|
||||
if (isset($_GET['cmd']) === true) {
|
||||
$host = 'redis-master';
|
||||
if (getenv('GET_HOSTS_FROM') == 'env') {
|
||||
$host = getenv('REDIS_MASTER_SERVICE_HOST');
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
if ($_GET['cmd'] == 'set') {
|
||||
$client = new Predis\Client([
|
||||
'scheme' => 'tcp',
|
||||
'host' => $host,
|
||||
'port' => 6379,
|
||||
]);
|
||||
|
||||
$client->set($_GET['key'], $_GET['value']);
|
||||
print('{"message": "Updated"}');
|
||||
} else {
|
||||
$host = 'redis-slave';
|
||||
if (getenv('GET_HOSTS_FROM') == 'env') {
|
||||
$host = getenv('REDIS_SLAVE_SERVICE_HOST');
|
||||
}
|
||||
$client = new Predis\Client([
|
||||
'scheme' => 'tcp',
|
||||
'host' => $host,
|
||||
'port' => 6379,
|
||||
]);
|
||||
|
||||
$value = $client->get($_GET['key']);
|
||||
print('{"data": "' . $value . '"}');
|
||||
}
|
||||
} else {
|
||||
phpinfo();
|
||||
} ?>
|
||||
Reference in New Issue
Block a user