PipelineContext.php 925 B

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