forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
37 lines (31 loc) · 949 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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();
} ?>