-
Notifications
You must be signed in to change notification settings - Fork 0
/
comment_poster.php
67 lines (41 loc) · 1.34 KB
/
comment_poster.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 2020, 7/25, pm 2:30
// post-comment.php
<?
require 'Predis/Autoloader.php';
Predis\Autoloader::register();
if(isset($_GET['cmd']) === true){
$host = 'master';
header('');
// to set or write to master;
if($_GET['cmd'] == 'set'){
$host = 'host';
header('Content-Type: application/json');
if(getenv('GET_HOSTS_FROM'=='env')){
$host = getenv('MASTER_SERVICE_HOST');
}
$client = new Predis\Client([
'schema' => 'tcp',
'host' => $host,
'port' => 6379
]);
$client->set($_GET['key'], $_GET['value']);
print('{"message": "update"}');
}else{
// to get or read from slave;
$hostS = 'slave';
if(getenv('GET_HOSTS_FROM'=='env'){
$hostS = 'SLAVE_SERVICE_HOST'
}
$clientS = new Predis\Client([
'schema' => 'tcp',
'host' => $hostS,
'port' => 6379
]);
$v = $clientS->get($_GET['key']);
print(' { "show data" : " ' . $v . ' "}');
}else{
phpinfo();
}
?>
<!-- 建立 rc/backend for this php -->
<!-- $kubectl create -f backend-controller.yaml -->