-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestclient.php
34 lines (26 loc) · 1.12 KB
/
testclient.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
<?php
use Eazybright\SimpleCache\SimpleCacheClient;
require "vendor/autoload.php";
use Grpc\ChannelCredentials;
use Eazybright\SimpleCache\DelRequest;
use Eazybright\SimpleCache\GetRequest;
use Eazybright\SimpleCache\SetRequest;
use Spiral\GRPC\StatusCode;
$client = new SimpleCacheClient(
'localhost:9090',
[
'credentials' => ChannelCredentials::createInsecure(),
]
);
[$response, $status] = $client->Set(new SetRequest(['Key' => 'hello', 'Value' => 'world']))->wait();
echo "================== SET ==================\n";
echo $response->getOK() === true, "\n";
[$response, $status] = $client->Get(new GetRequest(['Key' => 'hello']))->wait();
echo "================== GET ==================\n";
echo $response->getKey(), " : ", $response->getValue(), "\n";
[$response, $status] = $client->Del(new DelRequest(['Key' => 'hello']))->wait();
echo "================== DEL ==================\n";
echo $response->getOK() === true, "\n";
[$response, $status] = $client->Get(new GetRequest(['Key' => 'hello']))->wait();
echo "================== GET ==================\n";
echo $status->code === StatusCode::NOT_FOUND, "\n";