-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathtest.php
33 lines (24 loc) · 962 Bytes
/
test.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
<?php
require '../../vendor/autoload.php';
use Predis\Client;
// Environment variables
$host = getenv('REDIS_HOST');
$password = getenv('REDIS_PASSWORD');
// Client instance connected via TLS
$client = new Client("rediss://{$host}:6380?password={$password}");
// PING command
echo "Command PING\n";
echo "Command response: " . $client->ping() . "\n";
// GET command (non-existing key)
echo "Command GET Message\n";
echo "Command response: " . $client->get('Message') . "\n";
// SET command (set previous requested key)
echo "Command SET Message\n";
echo "Command response: " . $client->set('Message', 'Hello, I was set with Predis!') . "\n";
// Retry GET command and now get previously set value.
echo "Command GET Message\n";
echo "Command response: " . $client->get('Message') . "\n";
// CLIENT LIST command to check all connections to your Redis instance.
echo "Command CLIENT LIST\n";
echo "Command response: \n";
var_dump($client->client('LIST'));