Skip to content

Instantly share code, notes, and snippets.

@matdave
Created October 16, 2019 20:35
Show Gist options
  • Save matdave/e8bed147b9d22c23c85c0bddf3528d40 to your computer and use it in GitHub Desktop.
Save matdave/e8bed147b9d22c23c85c0bddf3528d40 to your computer and use it in GitHub Desktop.
Delay Clearing Cache on Resource Save
<?php
switch ($modx->event->name) {
case 'OnBeforeDocFormSave':
$now = mktime();
$lastcache = $modx->cacheManager->get('delaycache');
if(!empty($lastcache) && ($now - $lastcache) < 300){
$_POST['syncsite'] = 0;
}
return;
break;
case 'OnDocFormSave':
$now = mktime();
$lastcache = $modx->cacheManager->get('delaycache');
if(empty($lastcache)){
$modx->cacheManager->set('delaycache', $now, 300);
}
return;
break;
default:
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment