Search code examples
typo3extbasetypo3-9.x

where to store scheduler task related data in TYPO3


I'm working on an import script that loads data from a json feed. For this I need to save data at two moments:

1) when running the script I import a number of entries broken down into smaller chunks. This number can vary depending on what the feed delivers. Since I dont want to get the feed on every chunk but only once per import I would like to save the number of written entriers per run to have them available in the next run. Lets say I want to import 100 entries at 25/per run. That would make 4 runs. But now in one run only 20 out of the 25 are eligible for saving. So I'm 5 short at the end of the import. I would need to save the number of saved entries so I can do more runs if needed.

2) to find out how many entries should be imported I would like to save the id of the last imported item so I can check against this id in the next scheduler run of the import.

Where is the best place to safely save and access this data from extbase? The DB (seems excessive?)? The extension configuration (could not find a way to save data here, only read it)? Could I set custom temporary variables in $GLOBALS (at least for question 1)?

Thanks

EDIT: thanks to @Krzysztof Kasprzyca, this works:

// get registry
$registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Registry::class);

// get info
$alreadyImported = $registry->get('tx_my_ext_name', 'numberImported');

// set info
$alreadyImported = $registry->set('tx_my_ext_name', 'numberImported', $numberImported);

Solution

  • You can think about database table called sys_registry