class AcquiaPurgeQueueSmart in Acquia Purge 7
Efficient query bundling database queue that disregards expired queue items.
This backend drops items from the queue that have been sitting there twice as long as the sites TTL is configured to. All load balancers that once had the item in cache, are assumed to have already refreshed the item long ago.
Hierarchy
- class \SystemQueue implements DrupalReliableQueueInterface
- class \AcquiaPurgeQueueEfficient implements AcquiaPurgeQueueInterface
- class \AcquiaPurgeQueueSmart implements AcquiaPurgeQueueInterface
- class \AcquiaPurgeQueueEfficient implements AcquiaPurgeQueueInterface
Expanded class hierarchy of AcquiaPurgeQueueSmart
File
- lib/
queue/ AcquiaPurgeQueueSmart.php, line 15 - Contains SmartQueue.
View source
class AcquiaPurgeQueueSmart extends AcquiaPurgeQueueEfficient implements AcquiaPurgeQueueInterface {
/**
* Time in seconds Varnish is caching pages generated by Drupal.
*
* @var int
*/
protected $ttl = 0;
/**
* Construct a AcquiaPurgeQueueSmart instance.
*
* @param AcquiaPurgeStateStorageInterface $state
* The state storage required for the queue counters.
*/
public function __construct(AcquiaPurgeStateStorageInterface $state) {
parent::__construct($state);
$this->ttl = (int) variable_get('page_cache_maximum_age', 0);
}
/**
* Expire queue items that should have already expired externally.
*/
protected function expireQueueItems() {
// Do not bother expiry under the following conditions.
$expired = time() - 2 * $this->ttl;
if ($this->ttl < 20) {
return;
}
if ($expired < 1 || $expired >= time()) {
return;
}
// Delete items from the queue that expired and need no processing by AP.
$deleted_items = db_delete('queue')
->condition('name', $this->name)
->condition('created', $expired, '<')
->execute();
if ($deleted_items > 0) {
watchdog('acquia_purge', "Disregarded %n expired items from the queue (smart queue backend).", array(
'%n' => $deleted_items,
), WATCHDOG_INFO);
$this
->total()
->decrease($deleted_items);
}
}
/**
* {@inheritdoc}
*/
public function claimItem($lease_time = 30) {
$this
->expireQueueItems();
return parent::claimItem($lease_time);
}
/**
* {@inheritdoc}
*/
public function claimItemMultiple($claims = 10, $lease_time = 30) {
$this
->expireQueueItems();
return parent::claimItemMultiple($claims, $lease_time);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcquiaPurgeQueueEfficient:: |
protected | property | The queue item class to spawn queue items with. | |
AcquiaPurgeQueueEfficient:: |
protected | property | The state storage which holds the counter state items. | |
AcquiaPurgeQueueEfficient:: |
public | function |
Retrieve the failed purges counter. Overrides AcquiaPurgeQueueInterface:: |
|
AcquiaPurgeQueueEfficient:: |
public | function |
Add a queue item and store it directly to the queue. Overrides SystemQueue:: |
|
AcquiaPurgeQueueEfficient:: |
public | function |
Add multiple items to the queue and store them efficiently. Overrides AcquiaPurgeQueueInterface:: |
|
AcquiaPurgeQueueEfficient:: |
public | function |
Delete multiple items from the queue at once. Overrides AcquiaPurgeQueueInterface:: |
|
AcquiaPurgeQueueEfficient:: |
public | function |
Delete a queue and every item in the queue. Overrides SystemQueue:: |
|
AcquiaPurgeQueueEfficient:: |
public | function |
Retrieve the successful purges counter. Overrides AcquiaPurgeQueueInterface:: |
|
AcquiaPurgeQueueEfficient:: |
public | function |
Retrieve the number of items in the queue. Overrides SystemQueue:: |
|
AcquiaPurgeQueueEfficient:: |
public | function |
Release multiple items that the worker could not process. Overrides AcquiaPurgeQueueInterface:: |
|
AcquiaPurgeQueueEfficient:: |
public | function |
Retrieve the total queue items counter. Overrides AcquiaPurgeQueueInterface:: |
|
AcquiaPurgeQueueSmart:: |
protected | property | Time in seconds Varnish is caching pages generated by Drupal. | |
AcquiaPurgeQueueSmart:: |
public | function |
SystemQueue::claimItem() doesn't included expired items in its query
which means that it essentially breaks its own interface promise. Therefore
we overload the implementation with one that does do this accurately. This
should however flow back… Overrides AcquiaPurgeQueueEfficient:: |
|
AcquiaPurgeQueueSmart:: |
public | function |
Claims multiple items from the queue for processing. Overrides AcquiaPurgeQueueEfficient:: |
|
AcquiaPurgeQueueSmart:: |
protected | function | Expire queue items that should have already expired externally. | |
AcquiaPurgeQueueSmart:: |
public | function |
Construct a AcquiaPurgeQueueSmart instance. Overrides AcquiaPurgeQueueEfficient:: |
|
SystemQueue:: |
protected | property | The name of the queue this instance is working with. | |
SystemQueue:: |
public | function |
Create a queue. Overrides DrupalQueueInterface:: |
|
SystemQueue:: |
public | function |
Delete a finished item from the queue. Overrides DrupalQueueInterface:: |
|
SystemQueue:: |
public | function |
Release an item that the worker could not process, so another
worker can come in and process it before the timeout expires. Overrides DrupalQueueInterface:: |