Queue.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. class Redis_Queue implements DrupalReliableQueueInterface
  3. {
  4. /**
  5. * @var DrupalQueueInterface
  6. */
  7. protected $backend;
  8. /**
  9. * Default contructor
  10. *
  11. * Beware that DrupalQueueInterface does not defines the __construct
  12. * method in the interface yet is being used from DrupalQueue::get()
  13. *
  14. * @param unknown $name
  15. */
  16. public function __construct($name)
  17. {
  18. $className = Redis_Client::getClass(Redis_Client::REDIS_IMPL_QUEUE);
  19. $this->backend = new $className(Redis_Client::getClient(), $name);
  20. }
  21. public function createItem($data)
  22. {
  23. return $this->backend->createItem($data);
  24. }
  25. public function numberOfItems()
  26. {
  27. return $this->backend->numberOfItems();
  28. }
  29. public function claimItem($lease_time = 3600)
  30. {
  31. return $this->backend->claimItem($lease_time);
  32. }
  33. public function deleteItem($item)
  34. {
  35. return $this->backend->deleteItem($item);
  36. }
  37. public function releaseItem($item)
  38. {
  39. return $this->backend->releaseItem($item);
  40. }
  41. public function createQueue()
  42. {
  43. return $this->backend->createQueue();
  44. }
  45. public function deleteQueue()
  46. {
  47. return $this->backend->deleteQueue();
  48. }
  49. }