Аркадий

Аркадий

С нами с 08 февраля 2021; Место в рейтинге пользователей: #886
Аркадий
11 февраля 2021, 10:47
0
Наумов Алексей, спасибо больше, у меня отдельного класса нет, но ответ помог реализовать то, что хотелось, сделал так:
$cacheName = "asn1cache-" . basename($file) . "-" . filesize($file) . "-" . date('d.m.Y-H.i.s', filemtime($file));
$cachePartition = "asn1";
$output = $modx->cacheManager->get($cacheName,array(xPDO::OPT_CACHE_KEY=>$cachePartition));
if (empty($output))
{
....

    // Устанавливаем бессрочный кэш
    $modx->cacheManager->set($cacheName, $output, 0,array(xPDO::OPT_CACHE_KEY=>$cachePartition));
}
return $output;
И соответственно плагин, чтобы кэш очищался:
<?php
switch ($modx->event->name) {
    case 'OnSiteRefresh':
        if ($modx->cacheManager->refresh(array('asn1' => array()))) {
            $modx->log(modX::LOG_LEVEL_INFO, $modx->lexicon('refresh_default') . ': ASN1');
        }
        break;
}
Кэш теперь сохраняется в папке /core/asn1 и очищается только при очистке всего кэша