forked from shah-zobair/redis-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
57 lines (46 loc) · 2.29 KB
/
index.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
<?php
require "/opt/app-root/src/predis/autoload.php";
Predis\Autoloader::register();
session_start();
$i = isset($_SESSION['i']) ? $_SESSION['i'] : 0;
echo "Counter is = ";
echo ++$i;
$_SESSION['i'] = $i;
echo "<br><br>";
// 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();
//rfs-redisfailover.ha-redis-cluster.svc - 172.30.85.91 or 10.129.2.107?
// $redis = new Predis\Client(array("scheme" => "tcp","host" => "10.128.5.10","port" => 8001));
//$redis = new Predis\Client(array("scheme" => "tcp","host" => "172.30.57.94","port" => 6379));
//$redis = new Predis\Client(array("scheme" => "tcp","host" => "10.129.2.81","port" => 14626,"password"=> "testdb"));
//redis-14626.redis-ent-cluster.redis-ent-cluster.svc.cluster.local
//testdb.redis-ent-cluster.svc
$redis = new Predis\Client(array("scheme" => "tcp","host" => "testdb.redis-ent-cluster.svc", "port" => 14841,"password"=> "testdb"));
// $redis = new Predis\Client(array("scheme" => "tcp","host" => "172.30.174.153", "port" => 14626,"password"=> "testdb"));
//$sentinels = ['tcp://172.30.85.91'];
//$options = ['replication' => 'sentinel', 'service' => 'mymaster'];
//$redis = new Predis\Client($sentinels, $options);
echo "Successfully connected to Redis";
$redis->set("hello_world", "**********Hi from Swati Kale!*************");
$value = $redis->get("hello_world");
var_dump($value);
echo "<br>*****<br>";
$redis->set("visit_counter", $i);
$counter_value = $redis->get("visit_counter");
var_dump($counter_value);
$mkv = array('usr:0001' => 'OpenShift', 'usr:0002' => 'Fuse', 'usr:0003' => 'AMQ');
$redis->mset($mkv);
$retval = $redis->mget(array_keys($mkv));
print_r($retval);
echo "<br><br>";
//echo ($redis->exists("Aliens")) ? "true" : "false";
}
catch (Exception $e) {
echo "<br>Error encountered.<br>";
echo $e->getMessage();
}