Final Class Yiisoft\Queue\Stubs\InMemoryAdapter
| Inheritance | Yiisoft\Queue\Stubs\InMemoryAdapter |
|---|---|
| Implements | Yiisoft\Queue\Adapter\AdapterInterface |
In-memory implementation of {@see AdapterInterface} for testing and development purposes.
This adapter stores messages in a local array and processes them sequentially within the same process without any external queue backend. Messages are assigned incremental integer identifiers and are handled in FIFO order.
Note: This implementation is not persistent and should not be used in production, as all data is lost when the process ends.
Public Methods
Method Details
| public Yiisoft\Queue\Message\MessageInterface[] getMessagesList ( ) |
public function getMessagesList(): array
{
return array_values($this->messages);
}
| public Yiisoft\Queue\Message\MessageInterface push ( Yiisoft\Queue\Message\MessageInterface $message ) | ||
| $message | Yiisoft\Queue\Message\MessageInterface | |
public function push(MessageInterface $message): MessageInterface
{
$id = count($this->messages) + $this->current;
$this->messages[] = $message;
return new IdEnvelope($message, $id);
}
| public void runExisting ( callable $handlerCallback ) | ||
| $handlerCallback | callable | |
public function runExisting(callable $handlerCallback): void
{
$result = true;
while (isset($this->messages[$this->current]) && $result === true) {
$result = $handlerCallback($this->messages[$this->current]);
unset($this->messages[$this->current]);
$this->current++;
}
}
| public \Yiisoft\Queue\MessageStatus status ( integer|string $id ) | ||
| $id | integer|string | |
public function status(int|string $id): MessageStatus
{
$id = (int) $id;
if ($id < 0) {
return MessageStatus::NOT_FOUND;
}
if ($id < $this->current) {
return MessageStatus::DONE;
}
if (isset($this->messages[$id])) {
return MessageStatus::WAITING;
}
return MessageStatus::NOT_FOUND;
}
Signup or Login in order to comment.