dnet40/modules/uoa-stats/trunk/predis/examples/PipelineContext.php @ 40258
1 |
<?php
|
---|---|
2 |
|
3 |
/*
|
4 |
* This file is part of the Predis package.
|
5 |
*
|
6 |
* (c) Daniele Alessandri <suppakilla@gmail.com>
|
7 |
*
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
require 'SharedConfigurations.php'; |
13 |
|
14 |
// When you have a whole set of consecutive commands to send to
|
15 |
// a redis server, you can use a pipeline to improve performances.
|
16 |
|
17 |
$client = new Predis\Client($single_server); |
18 |
|
19 |
$replies = $client->pipeline(function ($pipe) { |
20 |
$pipe->ping(); |
21 |
$pipe->flushdb(); |
22 |
$pipe->incrby('counter', 10); |
23 |
$pipe->incrby('counter', 30); |
24 |
$pipe->exists('counter'); |
25 |
$pipe->get('counter'); |
26 |
$pipe->mget('does_not_exist', 'counter'); |
27 |
});
|
28 |
|
29 |
print_r($replies); |
30 |
|
31 |
/* OUTPUT:
|
32 |
Array
|
33 |
(
|
34 |
[0] => 1
|
35 |
[1] => 1
|
36 |
[2] => 10
|
37 |
[3] => 40
|
38 |
[4] => 1
|
39 |
[5] => 40
|
40 |
[6] => Array
|
41 |
(
|
42 |
[0] =>
|
43 |
[1] => 40
|
44 |
)
|
45 |
|
46 |
)
|
47 |
*/
|