forked from ORGANISATION-KA-INTERNATIONALE/FEDIVERSE-OKI
feat: add last podcast from castopod
This commit is contained in:
@@ -160,6 +160,26 @@ function callApiCached($cacheKey, $callable, $ttl = 900) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helpers simples pour le cache générique
|
||||
*/
|
||||
function getFromCache($key) {
|
||||
if (!defined('CACHE_ENABLED') || !CACHE_ENABLED) {
|
||||
return null;
|
||||
}
|
||||
$cache = $GLOBALS['simple_api_cache'];
|
||||
return $cache->get($key, []);
|
||||
}
|
||||
|
||||
function saveToCache($key, $data, $ttl = null) {
|
||||
if (!defined('CACHE_ENABLED') || !CACHE_ENABLED) {
|
||||
return;
|
||||
}
|
||||
$ttl = $ttl ?? (defined('CACHE_DURATION') ? CACHE_DURATION : 3600);
|
||||
$cache = $GLOBALS['simple_api_cache'];
|
||||
$cache->set($key, [], $data, $ttl);
|
||||
}
|
||||
|
||||
// Nettoyage automatique occasionnel
|
||||
if (rand(1, 100) === 1) {
|
||||
$GLOBALS['simple_api_cache']->cleanup();
|
||||
|
||||
Reference in New Issue
Block a user