当前位置: 首页>>代码示例>>PHP>>正文


PHP Queue::addItems方法代码示例

本文整理汇总了PHP中Queue::addItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Queue::addItems方法的具体用法?PHP Queue::addItems怎么用?PHP Queue::addItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Queue的用法示例。


在下文中一共展示了Queue::addItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAddItemsSync

 public function testAddItemsSync()
 {
     $queue = new Queue($this->redis, 'test', [Base::OPT_SLAVES_SYNC_ENABLED => true, Base::OPT_SLAVES_SYNC_REQUIRED_COUNT => 5]);
     try {
         $queue->addItems([1, 3, 5]);
     } catch (\PhpRQ\Exception\NotEnoughSlavesSynced $e) {
     }
     $this->assertSame(['5', '3', '1'], $this->redis->lrange('test', 0, 5));
     $this->assertKeys(['test']);
 }
开发者ID:jannavratil,项目名称:php-rq,代码行数:10,代码来源:QueueSyncTest.php

示例2: testRealUseCaseExample2

 public function testRealUseCaseExample2()
 {
     $message1 = new ExampleMessageObject();
     $message1->int = 1;
     $message1->float = 1.1;
     $message1->string = 'something1';
     $message1->bool = true;
     $message1Serialized = serialize($message1);
     $message2 = new ExampleMessageObject();
     $message2->int = 3;
     $message2->float = 3.3;
     $message2->string = 'something2';
     $message2->bool = false;
     $message2Serialized = serialize($message2);
     $message3 = new ExampleMessageObject();
     $message3->int = 4;
     $message3->float = 4.4;
     $message3->string = 'something3';
     $message3->bool = true;
     $message3Serialized = serialize($message3);
     $message4 = new ExampleMessageObject();
     $message4->int = 5;
     $message4->float = 5.5;
     $message4->string = 'something4';
     $message4->bool = false;
     $message4Serialized = serialize($message4);
     $message5 = new ExampleMessageObject();
     $message5->int = 6;
     $message5->float = 6.6;
     $message5->string = 'something5';
     $message5->bool = true;
     $message5Serialized = serialize($message5);
     $time = time();
     $queue = new Queue($this->redis, 'test');
     $processingQueue = sprintf('test-processing-%s[%d][%d]', gethostname(), getmypid(), $time);
     $queue->addItems([$message1, $message2, $message3, $message1, $message4, $message5]);
     $items = $queue->getItems(4);
     $this->assertSame([$message1Serialized, $message2Serialized, $message3Serialized, $message1Serialized], $items);
     $this->assertSame([$message5Serialized, $message4Serialized], $this->redis->lrange('test', 0, 5));
     $this->assertSame([$message1Serialized, $message3Serialized, $message2Serialized, $message1Serialized], $this->redis->lrange($processingQueue, 0, 10));
     $this->assertKeys(['test', $processingQueue, 'test-timeouts']);
     $queue->ackItem($message1);
     $queue->ackItems([$message2, $message3]);
     $queue->rejectBatch();
     $this->assertSame([$message5Serialized, $message4Serialized, $message1Serialized], $this->redis->lrange('test', 0, 5));
     $this->assertKeys(['test']);
     $items = $queue->getItems(5);
     $this->assertSame([$message1Serialized, $message4Serialized, $message5Serialized], $items);
     $this->assertSame([$message5Serialized, $message4Serialized, $message1Serialized], $this->redis->lrange($processingQueue, 0, 5));
     $this->assertKeys([$processingQueue, 'test-timeouts']);
     $queue->ackItems([$message1Serialized, $message4Serialized, $message5Serialized]);
     $this->assertKeys([]);
 }
开发者ID:jannavratil,项目名称:php-rq,代码行数:53,代码来源:QueueTest.php


注:本文中的Queue::addItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。