BatchMemory
class BatchMemory extends Memory (View source)
Defines a batch queue handler used by the Batch API for non-progressive batches.
This implementation:
- Ensures FIFO ordering.
- Allows an item to be repeatedly claimed until it is actually deleted (no notion of lease time or 'expire' date), to allow multipass operations.
Properties
| protected array | $queue | The queue data. |
from Memory |
| protected int | $idSequence | Counter for item ids. |
from Memory |
Methods
Overrides \Drupal\Core\Queue\Memory::claimItem().
Retrieves all remaining items in the queue.
Details
in
Memory at line 35
__construct(string $name)
Constructs a Memory object.
in
Memory at line 43
A
createItem($data)
Adds a queue item and store it directly to the queue.
in
Memory at line 56
int
numberOfItems()
Retrieves the number of items in the queue.
This is intended to provide a "best guess" count of the number of items in the queue. Depending on the implementation and the setup, the accuracy of the results of this function may vary.
e.g. On a busy system with a large number of consumers and items, the result might only be valid for a fraction of a second and not provide an accurate representation.
On
claimItem($lease_time = 0)
Overrides \Drupal\Core\Queue\Memory::claimItem().
Unlike \Drupal\Core\Queue\Memory::claimItem(), this method provides a default lease time of 0 (no expiration) instead of 30. This allows the item to be claimed repeatedly until it is deleted.
in
Memory at line 77
deleteItem($item)
Deletes a finished item from the queue.
in
Memory at line 84
bool
releaseItem($item)
Releases an item that the worker could not process.
Another worker can come in and process it before the timeout expires.
in
Memory at line 95
createQueue()
Creates a queue.
Called during installation and should be used to perform any necessary initialization operations. This should not be confused with the constructor for these objects, which is called every time an object is instantiated to operate on a queue. This operation is only needed the first time a given queue is going to be initialized (for example, to make a new database table or directory to hold tasks for the queue -- it depends on the queue implementation if this is necessary at all).
deleteQueue()
Deletes a queue and every item in the queue.
array
getAllItems()
Retrieves all remaining items in the queue.
This is specific to Batch API and is not part of the \Drupal\Core\Queue\QueueInterface.