class TxBuffer in Purge 8.3
Provides the transaction buffer.
Hierarchy
- class \Drupal\purge\Plugin\Purge\Queue\TxBuffer implements TxBufferInterface
Expanded class hierarchy of TxBuffer
2 files declare their use of TxBuffer
- ProxyItemTest.php in tests/
src/ Kernel/ Queue/ ProxyItemTest.php - TxBufferTest.php in tests/
src/ Kernel/ Queue/ TxBufferTest.php
1 string reference to 'TxBuffer'
1 service uses TxBuffer
File
- src/
Plugin/ Purge/ Queue/ TxBuffer.php, line 11
Namespace
Drupal\purge\Plugin\Purge\QueueView source
class TxBuffer implements TxBufferInterface {
/**
* Instances listing holding copies of each Invalidation object.
*
* @var \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface[]
*/
private $instances = [];
/**
* Instance<->state map of each object in the buffer.
*
* @var array|array[int]
*/
private $states = [];
/**
* Instance<->property map of each object in the buffer.
*
* @var array|array[int]
*/
private $properties = [];
/**
* {@inheritdoc}
*
* @see http://php.net/manual/en/countable.count.php
*/
public function count() {
return count($this->instances);
}
/**
* {@inheritdoc}
*
* @see http://php.net/manual/en/class.iterator.php
*/
public function current() {
return current($this->instances);
}
/**
* {@inheritdoc}
*/
public function delete($invalidations) {
if (!is_array($invalidations)) {
$invalidations = [
$invalidations,
];
}
foreach ($invalidations as $i) {
unset($this->instances[$i
->getId()]);
unset($this->states[$i
->getId()]);
unset($this->properties[$i
->getId()]);
}
}
/**
* {@inheritdoc}
*/
public function deleteEverything() {
$this->instances = [];
$this->states = [];
$this->properties = [];
}
/**
* {@inheritdoc}
*/
public function getByProperty($property, $value) {
foreach ($this->properties as $id => $properties) {
if (isset($properties[$property])) {
if ($properties[$property] === $value) {
return $this->instances[$id];
}
}
}
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getFiltered($states) {
if (!is_array($states)) {
$states = [
$states,
];
}
$results = [];
foreach ($this->states as $id => $state) {
if (in_array($state, $states)) {
$results[] = $this->instances[$id];
}
}
return $results;
}
/**
* {@inheritdoc}
*/
public function getState(InvalidationInterface $invalidation) {
if (!$this
->has($invalidation)) {
return NULL;
}
return $this->states[$invalidation
->getId()];
}
/**
* {@inheritdoc}
*/
public function getProperty(InvalidationInterface $invalidation, $property, $default = NULL) {
if (!isset($this->properties[$invalidation
->getId()][$property])) {
return $default;
}
return $this->properties[$invalidation
->getId()][$property];
}
/**
* {@inheritdoc}
*/
public function has(InvalidationInterface $invalidation) {
return isset($this->instances[$invalidation
->getId()]);
}
/**
* {@inheritdoc}
*
* @see http://php.net/manual/en/iterator.key.php
*/
public function key() {
return key($this->instances);
}
/**
* {@inheritdoc}
*
* @see http://php.net/manual/en/iterator.next.php
*/
public function next() {
return next($this->instances);
}
/**
* {@inheritdoc}
*
* @see http://php.net/manual/en/iterator.rewind.php
*/
public function rewind() {
return reset($this->instances);
}
/**
* {@inheritdoc}
*/
public function set($invalidations, $state) {
if (!is_array($invalidations)) {
$invalidations = [
$invalidations,
];
}
foreach ($invalidations as $i) {
if (!$i instanceof InvalidationInterface) {
throw new BadBehaviorException("Item is not a \\Drupal\\purge\\Plugin\\Purge\\Invalidation\\InvalidationInterface derivative.");
}
if (!$this
->has($i)) {
$this->instances[$i
->getId()] = $i;
}
$this->states[$i
->getId()] = $state;
}
}
/**
* {@inheritdoc}
*/
public function setProperty(InvalidationInterface $invalidation, $property, $value) {
if ($this
->has($invalidation)) {
$this->properties[$invalidation
->getId()][$property] = $value;
}
}
/**
* {@inheritdoc}
*
* @see http://php.net/manual/en/iterator.valid.php
*/
public function valid() {
return is_null(key($this->instances)) ? FALSE : TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TxBuffer:: |
private | property | Instances listing holding copies of each Invalidation object. | |
TxBuffer:: |
private | property | Instance<->property map of each object in the buffer. | |
TxBuffer:: |
private | property | Instance<->state map of each object in the buffer. | |
TxBuffer:: |
public | function | ||
TxBuffer:: |
public | function | ||
TxBuffer:: |
public | function |
Delete the given invalidation object from the buffer. Overrides TxBufferInterface:: |
|
TxBuffer:: |
public | function |
Delete everything in the buffer. Overrides TxBufferInterface:: |
|
TxBuffer:: |
public | function |
Retrieve a buffered object by property=value combination. Overrides TxBufferInterface:: |
|
TxBuffer:: |
public | function |
Only retrieve items from the buffer in a particular given state(s). Overrides TxBufferInterface:: |
|
TxBuffer:: |
public | function |
Retrieve a stored property for the given invalidation object. Overrides TxBufferInterface:: |
|
TxBuffer:: |
public | function |
Request the in-buffer set state for the given invalidation object. Overrides TxBufferInterface:: |
|
TxBuffer:: |
public | function |
Check if the given object is already in buffer our not. Overrides TxBufferInterface:: |
|
TxBuffer:: |
public | function | ||
TxBuffer:: |
public | function | ||
TxBuffer:: |
public | function | ||
TxBuffer:: |
public | function |
Set the given state on one or multiple invalidation objects. Overrides TxBufferInterface:: |
|
TxBuffer:: |
public | function |
Store a named property for the given invalidation object. Overrides TxBufferInterface:: |
|
TxBuffer:: |
public | function | ||
TxBufferInterface:: |
constant | Objects that just got added to the queue. | ||
TxBufferInterface:: |
constant | Objects in the process of being added to the queue. | ||
TxBufferInterface:: |
constant | Freshly claimed objects. | ||
TxBufferInterface:: |
constant | Objects in the process of being deleted from the queue. | ||
TxBufferInterface:: |
constant | Objects that just got released back to the queue. | ||
TxBufferInterface:: |
constant | Objects in the process of being released back to the queue. |