test_scan.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. use Redis\Logger\Reader;
  3. use Redis\Logger\Settings;
  4. $redis = new Redis();
  5. $redis->connect('localhost');
  6. require_once "lib/Redis/Logger/Settings.php";
  7. require_once "lib/Redis/Logger/Entry.php";
  8. require_once "lib/Redis/Logger/Reader.php";
  9. require_once "lib/Redis/Logger/Writer.php";
  10. $reader = new Reader($redis);
  11. echo "\nscan()-ing Template pattern: " . Settings::REDIS_PATTERN . "\n";
  12. echo implode(', ', $templates = $reader->scan(Settings::REDIS_PATTERN, 0, 50)) . "\n\n";
  13. echo "getChannels: ";
  14. $channels = $reader->getChannels();
  15. echo implode(', ', $channels) . "\n\n";
  16. echo "getTemplates():\n";
  17. $templates = $reader->getTemplates();
  18. echo "Result: " . implode(', ', $templates) . "\n\n";
  19. echo "getTemplates('cli'):\n";
  20. $templates = $reader->getTemplates("cli");
  21. echo "Result: " . implode(', ', $templates) . "\n\n";
  22. echo "getTemplates('foo'):\n";
  23. $templates = $reader->getTemplates("foo");
  24. echo "Result: " . implode(', ', $templates) . "\n\n";
  25. echo "getTemplates(NULL, 4):\n";
  26. $templates = $reader->getTemplates(NULL, 4);
  27. echo "Result: " . implode(', ', $templates) . "\n\n";
  28. echo "getTemplates(NULL, 5):\n";
  29. $templates = $reader->getTemplates(NULL, 5);
  30. echo "Result: " . implode(', ', $templates) . "\n\n";
  31. foreach ($reader->getTemplates() as $template) {
  32. echo "First page of events for template <$template>:\n";
  33. $entries = $reader->getEntries($template);
  34. foreach ($entries as $entry) {
  35. echo "$entry\n";
  36. }
  37. }
  38. echo "First page of events for template <nonexistent>:\n";
  39. $entries = $reader->getEntries("nonexistent");
  40. foreach ($entries as $entry) {
  41. echo "$entry\n";
  42. }