CommandPipeline.php 697 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. require_once 'SharedConfigurations.php';
  3. // When you have a whole set of consecutive commands to send to
  4. // a redis server, you can use a pipeline to improve performances.
  5. $redis = new Predis\Client($single_server);
  6. $replies = $redis->pipeline(function($pipe) {
  7. $pipe->ping();
  8. $pipe->flushdb();
  9. $pipe->incrby('counter', 10);
  10. $pipe->incrby('counter', 30);
  11. $pipe->exists('counter');
  12. $pipe->get('counter');
  13. $pipe->mget('does_not_exist', 'counter');
  14. });
  15. print_r($replies);
  16. /* OUTPUT:
  17. Array
  18. (
  19. [0] => 1
  20. [1] => 1
  21. [2] => 10
  22. [3] => 40
  23. [4] => 1
  24. [5] => 40
  25. [6] => Array
  26. (
  27. [0] =>
  28. [1] => 40
  29. )
  30. )
  31. */
  32. ?>