refactored the cache loader

- adjusted formatting to make it easier to read
- added the key prefix from config
- made everything failsafe since users don't have that configured by default
This commit is contained in:
HB9HIL
2026-02-01 20:21:14 +01:00
parent 6299e02e81
commit 9e19dec6bf
8 changed files with 40 additions and 8 deletions

View File

@@ -18,7 +18,11 @@ class Sattimers extends CI_Controller {
$url = 'https://www.df2et.de/tevel/api2.php?grid='.strtoupper($this->stations->find_gridsquare());
$this->load->driver('cache', ['adapter' => $this->config->item('cache_adapter'), 'backup' => $this->config->item('cache_backup')]);
$this->load->driver('cache', [
'adapter' => $this->config->item('cache_adapter') ?? 'file',
'backup' => $this->config->item('cache_backup') ?? 'file',
'key_prefix' => $this->config->item('cache_key_prefix') ?? ''
]);
if (!$RawData = $this->cache->get('SatTimers'.strtoupper($this->stations->find_gridsquare()))) {
$RawData = file_get_contents($url, true);
$this->cache->save('SatTimers'.strtoupper($this->stations->find_gridsquare()), $RawData, (60*1));