forked from mtaneja/php-pecl-memcache-zynga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetByKey.php
40 lines (30 loc) · 1.01 KB
/
setByKey.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
<?php
require_once("init.php");
$memcache = new memcache;
$memcache->debug(DEBUG);
$memcache->addServer("localhost", 11211);
if ($memcache) {
$timeout = 1209600;
$cas = 0;
$val = "value1";
$key = "foo";
$flag = false;
$shardKey = "foo";
$result = $memcache->setByKey($key, $val, $flag, $timeout, $cas, $shardKey);
echo "key '$key' shardKey '$shardKey' result '$result' val: '$val' flag '$flag' timeout '$timeout' cas '$cas'\n";
$val = "value2";
$key = "foo";
$flag = false;
$shardKey = "123";
$result = $memcache->setByKey($key, $val, $flag, $timeout, $cas, $shardKey);
echo "key '$key' shardKey '$shardKey' result '$result' val: '$val' flag '$flag' timeout '$timeout' cas '$cas'\n";
$val = "value3";
$key = "fa;dfa;dfa;sdf;safoo";
$flag = false;
$shardKey = "123";
$result = $memcache->setByKey($key, $val, $flag, $timeout, $cas, $shardKey);
echo "key '$key' shardKey '$shardKey' result '$result' val: '$val' flag '$flag' timeout '$timeout' cas '$cas'\n";
} else {
echo "Connection failed\n";
}
?>