forked from RedisLabs/memcachedcloud-php-sample
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommand.php
More file actions
28 lines (27 loc) · 731 Bytes
/
command.php
File metadata and controls
28 lines (27 loc) · 731 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
<?php
$mc = new Memcached();
$mc->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$mc->addServers(array_map(function($server) { return explode(':', $server, 2); }, explode(',', $_ENV['MEMCACHEDCLOUD_SERVERS'])));
$mc->setSaslAuthData($_ENV['MEMCACHEDCLOUD_USERNAME'], $_ENV['MEMCACHEDCLOUD_PASSWORD']);
switch ($_GET['a']) {
case 'set':
echo $mc->set('welcome_msg', 'Hello from Redis!');
break;
case 'get':
echo $mc->get('welcome_msg');
break;
case 'stats':
foreach ($mc->getStats() as $key => $value) {
foreach ($value as $k => $v) {
echo "$k: $v <br />\n";
}
}
break;
case 'delete':
echo $mc->delete('welcome_msg');
break;
default:
echo '';
break;
}
?>