CMS39 caching uses symfony/cache: Redis when available, files otherwise. Every value has tags, and changing a piece of content clears only what depends on it.
API
$key = 'my_widget_' . CURRENT_LANG;
if (cms39_cache_has($key)) {
$html = cms39_cache_fetch($key);
} else {
$html = my_widget_render();
cms39_cache_add($key, $html, ['post_48', 'menus'], ['ttl' => 3600]);
}
cms39_cache_empty(['post_48']); // clears everything with this tag
cms39_cache_clear(); // everythingWith caching off, the same functions work with memory for the current request only, so your code needs no checks.
External APIs
Every call to an external service from a page goes through cms39_remember_external. The result is stored in a file; once it expires, visitors immediately get the old value while the new one is fetched after the response. Nobody waits for the API.
$weather = cms39_remember_external('weather_athens', function () {
$json = my_http_get('https://api.example.com/weather?city=athens', 2); // short timeout
return [$json, $json !== null]; // [value, ok]
}, 1800, 300); // ttl, failure ttlE-MAIL or by phone at (+30) +30.2152151245-8