-
Notifications
You must be signed in to change notification settings - Fork 7
/
redis_noget.php
43 lines (33 loc) · 1014 Bytes
/
redis_noget.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
<?PHP
$redis = new Redis();
$redis->connect('127.0.0.1', 6389);
//$redis->connect('192.168.111.2', 6379);
$value = randString(10000);
$start = microtime(True);
for ($i = 0; $i<1000; $i++) {
$key = randString(32);
$response = $redis->ping();
if ($response != "+PONG" && $response != "+OK") {
print("Error in PING $response\n");
exit(1);
}
$response = $redis->set($key, $value, 600);
if ($response === False) {
printf("Error in SET %s %s\n", $response, $key);
exit(1);
}
$redis->hSet("ROW", $key, $value);
$redis->hDel("ROW", $key);
$redis->del($key, $value);
}
$elapsed = microtime(True)-$start;
printf("Elapsed %.2f\n", $elapsed);
function randString($maxLen) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
$len = strlen($characters);
for ($i = 0; $i < $maxLen; $i++) {
$randomString .= $characters[rand(0, $len - 1)];
}
return $randomString;
}