| Conditions | 2 |
| Paths | 2 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 7 | public function queueObject($object) |
||
| 8 | { |
||
| 9 | global $redis; |
||
|
|
|||
| 10 | |||
| 11 | $wrapped = serialize($object); |
||
| 12 | |||
| 13 | $allQueues = new RedisTtlSortedSet('redisQ:allQueues'); |
||
| 14 | $objectQueues = new RedisTtlSortedSet('objectQueues'); |
||
| 15 | $queues = $allQueues->getMembers(); |
||
| 16 | |||
| 17 | $multi = $redis->multi(); |
||
| 18 | |||
| 19 | // Store an instance of the object |
||
| 20 | $objectID = 'redisQ:objectID:'.uniqID().md5($wrapped); |
||
| 21 | $objectQueues->add(time(), $objectID); |
||
| 22 | $multi->setex($objectID, 9600, $wrapped); |
||
| 23 | |||
| 24 | // Add objectID to all queues |
||
| 25 | foreach ($queues as $queueID) { |
||
| 26 | $multi->lPush($queueID, $objectID); |
||
| 27 | $multi->expire($queueID, 9600); |
||
| 28 | } |
||
| 29 | $multi->exec(); |
||
| 30 | } |
||
| 31 | |||
| 57 |
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state