-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_client.php
executable file
·73 lines (56 loc) · 2.52 KB
/
test_client.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
68
69
70
71
72
73
<?php
use Dpl\SimpleCache\SimpleCacheClient;
require "vendor/autoload.php";
use Grpc\ChannelCredentials;
use Dpl\SimpleCache\DelRequest;
use Dpl\SimpleCache\GetRequest;
use Dpl\SimpleCache\SetRequest;
use Spiral\GRPC\StatusCode;
$client = new SimpleCacheClient(
'dplgrpc-service:9090',
[
'credentials' => ChannelCredentials::createInsecure(),
]
);
[$response, $status] = $client->Set(new SetRequest(['key' => 'my_key1', 'value' => 'this']))->wait();
echo "================== SET ==================\n";
echo $response->getSuccess() === true, "\n";
[$response, $status] = $client->Set(new SetRequest(['key' => 'my_key2', 'value' => 'is']))->wait();
echo "================== SET ==================\n";
echo $response->getSuccess() === true, "\n";
[$response, $status] = $client->Set(new SetRequest(['key' => 'my_key3', 'value' => 'Sparta']))->wait();
echo "================== SET ==================\n";
echo $response->getSuccess() === true, "\n";
[$response, $status] = $client->Get(new GetRequest(['key' => 'my_key1']))->wait();
echo "================== GET ==================\n";
echo $response->getkey(), " : ", $response->getvalue(), "\n";
[$response, $status] = $client->Get(new GetRequest(['key' => 'my_key2']))->wait();
echo "================== GET ==================\n";
echo $response->getkey(), " : ", $response->getvalue(), "\n";
[$response, $status] = $client->Get(new GetRequest(['key' => 'my_key3']))->wait();
echo "================== GET ==================\n";
echo $response->getkey(), " : ", $response->getvalue(), "\n";
[$response, $status] = $client->Del(new DelRequest(['key' => 'my_key3']))->wait();
echo "================== DEL ==================\n";
echo $response->getSuccess() === true, "\n";
[$response, $status] = $client->Get(new GetRequest(['key' => 'my_key1']))->wait();
echo "================== GET ==================\n";
if ($status->code == StatusCode::NOT_FOUND) {
echo 'Not found', "\n";
} else {
echo $response->getkey(), " : ", $response->getvalue(), "\n";
}
[$response, $status] = $client->Get(new GetRequest(['key' => 'my_key2']))->wait();
echo "================== GET ==================\n";
if ($status->code == StatusCode::NOT_FOUND) {
echo 'Not found', "\n";
} else {
echo $response->getkey(), " : ", $response->getvalue(), "\n";
}
[$response, $status] = $client->Get(new GetRequest(['key' => 'my_key3']))->wait();
echo "================== GET ==================\n";
if ($status->code == StatusCode::NOT_FOUND) {
echo 'Not found', "\n";
} else {
echo $response->getkey(), " : ", $response->getvalue(), "\n";
}