-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
30 lines (24 loc) · 992 Bytes
/
index.php
File metadata and controls
30 lines (24 loc) · 992 Bytes
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
<?php
require "/opt/app-root/src/predis/autoload.php";
Predis\Autoloader::register();
// since we connect to default setting localhost
// and 6379 port there is no need for extra
// configuration. If not then you can specify the
// scheme, host and port to connect as an array
// to the constructor.
try {
// $redis = new Predis\Client();
$redis = new Predis\Client(array(
"scheme" => "tcp",
"host" => "172.30.104.84",
"port" => 6379));
echo "Successfully connected to Redis";
$redis->set("hello_world", "Hi from php!");
$value = $redis->get("hello_world");
var_dump($value);
echo ($redis->exists("Santa Claus")) ? "true" : "false";
}
catch (Exception $e) {
echo "Couldn't connected to Redis";
echo $e->getMessage();
}