| @@ 69-89 (lines=21) @@ | ||
| 66 | * |
|
| 67 | * @return Command|null |
|
| 68 | */ |
|
| 69 | public function pop() |
|
| 70 | { |
|
| 71 | $value = $this->client->lpop(self::LIST_KEY); |
|
| 72 | ||
| 73 | if (!$value) { |
|
| 74 | return null; |
|
| 75 | } |
|
| 76 | ||
| 77 | try { |
|
| 78 | return $this->serializer->denormalize($value, Command::class, self::FORMAT); |
|
| 79 | } catch (\Exception $e) { |
|
| 80 | // it's a critical error |
|
| 81 | // it is necessary to react quickly to it |
|
| 82 | $this->logger->critical('Failed denormalize a command in the Redis queue', [$value, $e->getMessage()]); |
|
| 83 | ||
| 84 | // try denormalize in later |
|
| 85 | $this->client->rpush(self::LIST_KEY, [$value]); |
|
| 86 | ||
| 87 | return null; |
|
| 88 | } |
|
| 89 | } |
|
| 90 | } |
|
| 91 | ||
| @@ 72-92 (lines=21) @@ | ||
| 69 | * |
|
| 70 | * @return Command|null |
|
| 71 | */ |
|
| 72 | public function pop() |
|
| 73 | { |
|
| 74 | $value = $this->client->lpop(self::LIST_KEY); |
|
| 75 | ||
| 76 | if (!$value) { |
|
| 77 | return null; |
|
| 78 | } |
|
| 79 | ||
| 80 | try { |
|
| 81 | return $this->serializer->denormalize($value, Command::class, self::FORMAT); |
|
| 82 | } catch (\Exception $e) { |
|
| 83 | // it's a critical error |
|
| 84 | // it is necessary to react quickly to it |
|
| 85 | $this->logger->critical('Failed denormalize a command in the Redis queue', [$value, $e->getMessage()]); |
|
| 86 | ||
| 87 | // try denormalize in later |
|
| 88 | $this->client->rpush(self::LIST_KEY, [$value]); |
|
| 89 | ||
| 90 | return null; |
|
| 91 | } |
|
| 92 | } |
|
| 93 | } |
|
| 94 | ||