Skip to content
Extraits de code Groupes Projets
Valider f00f981c rédigé par kent1's avatar kent1
Parcourir les fichiers

PSR SPIP

parent de0b4c35
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -84,9 +84,9 @@ function taille_du_cache() { ...@@ -84,9 +84,9 @@ function taille_du_cache() {
$time = isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0; $time = isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0;
for ($i=0; $i < 256; $i++) { for ($i=0; $i < 256; $i++) {
$dir = _DIR_CACHE.sprintf('%02s', dechex($i)); $dir = _DIR_CACHE.sprintf('%02s', dechex($i));
if (@is_dir($dir) AND is_readable($dir) AND $d = opendir($dir)) { if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
while (($f = readdir($d)) !== false) { while (($f = readdir($d)) !== false) {
if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) AND $a = stat("$dir/$f")) { if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) {
$n++; $n++;
if ($a['mtime'] >= $time) { if ($a['mtime'] >= $time) {
if ($a['blocks'] > 0) { if ($a['blocks'] > 0) {
...@@ -153,7 +153,6 @@ function suivre_invalideur($cond, $modif = true) { ...@@ -153,7 +153,6 @@ function suivre_invalideur($cond, $modif = true) {
else { else {
ecrire_meta('derniere_modif', time()); ecrire_meta('derniere_modif', time());
} }
} }
...@@ -243,7 +242,7 @@ function appliquer_quota_cache() { ...@@ -243,7 +242,7 @@ function appliquer_quota_cache() {
list($nombre, $taille) = nombre_de_fichiers_repertoire($dir); list($nombre, $taille) = nombre_de_fichiers_repertoire($dir);
$total_cache = $taille * $nombre; $total_cache = $taille * $nombre;
spip_log("Taille du CACHE estimee ($l): " spip_log("Taille du CACHE estimee ($l): "
. (intval(16 * $total_cache / (1024 * 1024 / 10)) / 10) . " Mo", "invalideur"); . (intval(16 * $total_cache / (1024 * 1024 / 10)) / 10) . ' Mo', 'invalideur');
// Nombre max de fichiers a supprimer // Nombre max de fichiers a supprimer
if ($GLOBALS['quota_cache'] > 0 if ($GLOBALS['quota_cache'] > 0
...@@ -252,16 +251,17 @@ function appliquer_quota_cache() { ...@@ -252,16 +251,17 @@ function appliquer_quota_cache() {
$trop = $total_cache - ($GLOBALS['quota_cache'] / 16) * 1024 * 1024; $trop = $total_cache - ($GLOBALS['quota_cache'] / 16) * 1024 * 1024;
$trop = 3 * intval($trop / $taille); $trop = 3 * intval($trop / $taille);
if ($trop > 0) { if ($trop > 0) {
$n = purger_repertoire($dir, $n = purger_repertoire(
$dir,
array( array(
'atime' => time() - _AGE_CACHE_ATIME, 'atime' => time() - _AGE_CACHE_ATIME,
'limit' => $trop, 'limit' => $trop,
'subdir' => true // supprimer les vieux sous repertoire de session (avant [15851]) 'subdir' => true // supprimer les vieux sous repertoire de session (avant [15851])
) )
); );
spip_log("$dir : $n/$trop caches supprimes [taille moyenne $taille]", "invalideur"); spip_log("$dir : $n/$trop caches supprimes [taille moyenne $taille]", 'invalideur');
$total_cache = intval(max(0, (16 * $total_cache) - $n * $taille) / (1024 * 1024) * 10) / 10; $total_cache = intval(max(0, (16 * $total_cache) - $n * $taille) / (1024 * 1024) * 10) / 10;
spip_log("cache restant estime : $total_cache Mo, ratio " . $total_cache / $GLOBALS['quota_cache'], "invalideur"); spip_log("cache restant estime : $total_cache Mo, ratio " . $total_cache / $GLOBALS['quota_cache'], 'invalideur');
// redemander la main pour eviter que le cache ne gonfle trop // redemander la main pour eviter que le cache ne gonfle trop
// mais pas si on ne peut pas purger car les fichiers sont trops recents // mais pas si on ne peut pas purger car les fichiers sont trops recents
...@@ -270,7 +270,7 @@ function appliquer_quota_cache() { ...@@ -270,7 +270,7 @@ function appliquer_quota_cache() {
and $n * 50 > $trop and $n * 50 > $trop
) { ) {
$encore = true; $encore = true;
spip_log("Il faut encore purger", "invalideur"); spip_log('Il faut encore purger', 'invalideur');
} }
} }
} }
...@@ -288,8 +288,9 @@ function appliquer_quota_cache() { ...@@ -288,8 +288,9 @@ function appliquer_quota_cache() {
function retire_cache($cache) { function retire_cache($cache) {
if (preg_match( if (preg_match(
"|^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$|i", ',^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$,i',
$cache)) { $cache
)) {
// supprimer le fichier (de facon propre) // supprimer le fichier (de facon propre)
supprimer_fichier(_DIR_CACHE . $cache); supprimer_fichier(_DIR_CACHE . $cache);
} else { } else {
...@@ -329,20 +330,25 @@ function calcul_invalideurs($corps, $primary, &$boucles, $id_boucle) { ...@@ -329,20 +330,25 @@ function calcul_invalideurs($corps, $primary, &$boucles, $id_boucle) {
// invoquee quand on vide tout le cache en bloc (action/purger) // invoquee quand on vide tout le cache en bloc (action/purger)
// //
// http://code.spip.net/@supprime_invalideurs // http://code.spip.net/@supprime_invalideurs
function supprime_invalideurs() { } function supprime_invalideurs() {
}
// Calcul des pages : noter dans la base les liens d'invalidation // Calcul des pages : noter dans la base les liens d'invalidation
// http://code.spip.net/@maj_invalideurs // http://code.spip.net/@maj_invalideurs
function maj_invalideurs($fichier, &$page) { } function maj_invalideurs($fichier, &$page) {
}
// les invalideurs sont de la forme "objet/id_objet" // les invalideurs sont de la forme "objet/id_objet"
// http://code.spip.net/@insere_invalideur // http://code.spip.net/@insere_invalideur
function insere_invalideur($inval, $fichier) { } function insere_invalideur($inval, $fichier) {
}
// //
// Marquer les fichiers caches invalides comme etant a supprimer // Marquer les fichiers caches invalides comme etant a supprimer
// //
// http://code.spip.net/@applique_invalideur // http://code.spip.net/@applique_invalideur
function applique_invalideur($depart) { } function applique_invalideur($depart) {
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter