Skip to content

Commit

Permalink
Merge pull request #194 from quantcdn/feature/queue-unique-info
Browse files Browse the repository at this point in the history
Added warning and info for queue factory.
  • Loading branch information
kepol authored Jan 18, 2024
2 parents ad4b65e + 1c9a80d commit c039587
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
25 changes: 24 additions & 1 deletion modules/quant_purger/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
# Quant cache tag purger

Adds a cache tag plugin which listen to invalidation events to queue Quant repopulation. This allows node_saves to update the main page but also trigger updates for pages that might be affected by the content update (eg. views pages). These will be added to the queue for the next core cron run to publish the updates.
Adds a cache tag plugin which listens to Drupal invalidation events in order to
queue Quant updates for related content.

For example, this allows node edits to trigger the main (`/node`) page to update
along with any other pages associated with the node through cache tags (e.g.
views pages, taxonomy term pages, etc).

This also works with other entities. For example, if a term is associated with
several nodes, those nodes will be queued for updates when the term is edited.

To ensure that queued content is processed in a timely manner, you can set up a
Quant cron process that is separate from the core cron which just processes the
Quant queue. This Quant cron can be run more regularly than the core cron.

See [Quant Purger documentation](https://docs.quantcdn.io/docs/integrations/drupal/purger)
for additional information.

## Requirements

- quant
- purge

## Recommendations

For the best performance, it is highly recommended that your settings include:

```
$settings['queue_service_quant_seed_worker'] = 'quant.queue_factory';
```
8 changes: 7 additions & 1 deletion quant.module
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\Url;
use Drupal\node\NodeInterface;
use Drupal\quant\Exception\TokenValidationDisabledException;
Expand Down Expand Up @@ -439,10 +440,15 @@ function quant_preprocess_page(&$variables) {
// Show the Quant page info block for non-admin pages if enabled.
$config = \Drupal::configFactory()->getEditable('quant.settings');
$enabled = $config->get('quant_show_page_info_block');

if ($enabled && !\Drupal::service('router.admin_context')->isAdminRoute()) {
$variables['page']['content']['#prefix'] = Utility::getPageInfo() . ($variables['page']['content']['#prefix'] ?? '');
}

// Add warning on Quant admin pages if queue factory is not set.
$current_path = \Drupal::requestStack()->getCurrentRequest()->getPathInfo();
if ((strpos($current_path, '/admin/config/quant') === 0) && Settings::get('queue_service_quant_seed_worker') != "quant.queue_factory") {
\Drupal::messenger()->addWarning(t('For the best performance, it is highly recommended you update <em>queue_service_quant_seed_worker</em> in your settings. See the <a href="https://docs.quantcdn.io/docs/integrations/drupal">Drupal docs</a> for setup information.'));
}
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/QuantQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function doCreateItem($data) {
return $query->execute();
}
catch (IntegrityConstraintViolationException $err) {
var_dump('skipping cause exists');
return FALSE;
}
}
Expand Down

0 comments on commit c039587

Please sign in to comment.