Changeset 115318 in spip-zone
- Timestamp:
- May 10, 2019, 5:11:46 PM (2 years ago)
- Location:
- _plugins_
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/cachelab/trunk/cachelab_fonctions.php
r112102 r115318 3 3 4 4 include_spip('public/cachelab_balises'); 5 6 // mémo des defines : 7 8 // loger tous les temps des ciblages 9 if (!defined('LOG_CACHELAB_CHRONO')) 10 define('LOG_CACHELAB_CHRONO', false); 11 12 // Seuil minimal des temps de ciblage à loger dans cachelab_slow (en ms) 13 if (!defined('LOG_CACHELAB_SLOW')) 14 define('LOG_CACHELAB_SLOW', 70); 15 16 // Seuil minimal du nombre de caches invalidés en un seul ciblage pour le loger dans cachelab_toomany_del 17 if (!defined('LOG_CACHELAB_TOOMANY_DEL')) 18 define('LOG_CACHELAB_TOOMANY_DEL',100); 19 20 if (!defined('LOG_BALISECACHE_FILTRES')) 21 define('LOG_BALISECACHE_FILTRES', 'oui'); 22 23 if (!defined('LOG_BALISECACHE_DUREES_DYNAMIQUES')) 24 define('LOG_BALISECACHE_DUREES_DYNAMIQUES', false); 25 26 define ('_CACHELAB_FONCTIONS', true); -
_plugins_/cachelab/trunk/inc/cachelab.php
r114347 r115318 17 17 * @return bool : indique si l'action a pu être appliquée ou non 18 18 */ 19 function cachelab_applique ($action, $cle, $data=null, $options='', &$return=null) {19 function cachelab_appliquer ($action, $cle, $data=null, $options='', &$return=null) { 20 20 global $Memoization; 21 21 if (!isset($Memoization) or !$Memoization) { 22 spip_log("cachelab_applique ($action, $cle...) : Memoization n'est pas activé", 'cachelab_erreur');22 spip_log("cachelab_appliquer ($action, $cle...) : Memoization n'est pas activé", 'cachelab_erreur'); 23 23 return false; 24 24 } … … 33 33 $del = $Memoization->del($joliecle); 34 34 if (!$del) { 35 spip_log ("Échec 'del' $joliecle", 'cachelab ');35 spip_log ("Échec 'del' $joliecle", 'cachelab_erreur'); 36 36 return false; 37 37 }; … … 64 64 65 65 default : 66 $f = 'cachelab_applique _'.$action;66 $f = 'cachelab_appliquer_'.$action; 67 67 if (function_exists($f)) 68 68 return $f($action, $cle, $data, $options, $return); … … 81 81 * @uses apcu_cache_info() et donc nécessite que Memoization soit activé avec APC ou APCu 82 82 * 83 * @param $action : l'action à appliquer83 * @param string $action : l'action à appliquer 84 84 * @param array $conditions : les conditions définissant la cible 85 85 * @param array $options : options de l'action et/ou des conditions … … 136 136 // pas de listes par défaut 137 137 $do_lists = ($action == 'list') or (isset ($options['list']) and $options['list']); 138 // pas de chrono par défaut sauf si CACHELAB_CHRONO 139 $do_chrono = (isset ($options['chrono']) ? $options['chrono'] : (defined('CACHELAB_CHRONO') and CACHELAB_CHRONO)); 140 if ($do_chrono) { 141 include_spip ('lib/microtime.inc'); 142 microtime_do ('begin'); 143 } 138 include_spip ('lib/microtime.inc'); 139 microtime_do ('begin'); 144 140 145 141 // retours 146 142 $stats=array(); 147 $stats['nb_alien']=$stats['nb_candidats']=$stats['nb_clean']=$stats['nb_ no_data']=$stats['nb_not_array']=$stats['nb_cible']=0;148 $stats['l_ no_data'] = $stats['l_not_array'] = $stats['l_cible'] = array();143 $stats['nb_alien']=$stats['nb_candidats']=$stats['nb_clean']=$stats['nb_cible']=0; 144 $stats['l_cible'] = array(); 149 145 150 146 // On y va … … 233 229 global $Memoization; 234 230 $data = $Memoization->get(substr($cle, $len_prefix)); 235 if (!$data) { 236 $stats['nb_no_data']++; 237 continue; 238 } 239 if (!is_array($data)) { 240 spip_log ("clé=$cle : data n'est pas un tableau : ".print_r($data,1), 'cachelab'); 241 $stats['nb_not_array']++; 242 if ($do_lists) 243 $stats['l_not_array'][] = $cle; 231 if (!$data or !is_array($data)) { 232 spip_log ("clé=$cle : data est vide ou n'est pas un tableau : ".print_r($data,1), 'cachelab_erreur'); 244 233 continue; 245 234 }; … … 262 251 $stats['l_cible'][] = $cle; 263 252 264 cachelab_applique ($action, $cle, $data, $options, $return);253 cachelab_appliquer ($action, $cle, $data, $options, $return); 265 254 266 255 if ($return 267 256 and (($action=='get') 268 257 or (substr($action,0,4)=='get_'))) 269 return $return; 270 } 271 272 if ($do_chrono) { 273 $stats['chrono'] = microtime_do ('end', 'ms'); 274 spip_log ("cachelab_cibler ($action, session=$session, objet $cle_objet=$id_objet, chemin=$chemin) : {$stats['nb_cible']} caches ciblés (sur {$stats['nb_candidats']}) en {$stats['chrono']} ms", 'cachelab'); 275 } 258 return $return; // TODO chrono aussi dans ce cas 259 } 260 261 $stats['chrono'] = microtime_do ('end', 'ms'); 262 $msg = "cachelab_cibler($action) en {$stats['chrono']} ms ({$stats['nb_cible']} caches sur {$stats['nb_candidats']})" 263 ."\n".print_r($conditions, 1); 264 if (count($options)) 265 $msg .= "\n".print_r($options, 1); 266 if (defined ('LOG_CACHELAB_CHRONO') and LOG_CACHELAB_CHRONO) 267 spip_log ($msg, 'cachelab_chrono.'._LOG_INFO); 268 if (defined ('LOG_CACHELAB_SLOW') and ($stats['chrono'] > LOG_CACHELAB_SLOW)) 269 spip_log ($msg, 'cachelab_slow.'._LOG_INFO_IMPORTANTE); 270 if (($action=='del') and defined ('LOG_CACHELAB_TOOMANY_DEL') and ($stats['nb_cible'] > LOG_CACHELAB_TOOMANY_DEL)) 271 spip_log ($msg, 'cachelab_toomany_del.'._LOG_INFO_IMPORTANTE); 276 272 277 273 if ($return) -
_plugins_/cachelab/trunk/inc/cachelab_invalideur.php
r113348 r115318 75 75 } 76 76 else 77 spip_log ("invalidation évitée : $cond", "cachelab_not");77 spip_log ("invalidation totale évitée : $cond", "cachelab_effondrement_evite"); 78 78 } 79 79 … … 131 131 $duree = $f($page['contexte'][$arg],$page); 132 132 if (!is_null($duree)) { 133 if (!defined('LOG_ CACHELAB_DUREES_DYNAMIQUES') or LOG_CACHELAB_DUREES_DYNAMIQUES)134 spip_log ("#CACHE $f (arg={$page['contexte'][$arg]}) renvoie : $duree s", "cachelab");133 if (!defined('LOG_BALISECACHE_DUREES_DYNAMIQUES') or LOG_CACHELAB_DUREES_DYNAMIQUES) 134 spip_log ("#CACHE $f (arg={$page['contexte'][$arg]}) renvoie : $duree s", 'balisecache_duree_dynamique'); 135 135 136 136 if ($var_cache) … … 140 140 $page['entetes']['X-Spip-Cache']=$duree; 141 141 142 // On garde un souvenir142 // Commenté : on garde un souvenir 143 143 // unset ($page['entetes']['X-Spip-Methode-Duree-Cache']); 144 144 145 // Dans le core, creer_cache appelle maj_invalideurs *aprés* d'avoir écrit le cache, 146 // mais l'inverse semble pas possible selon cerdic pour cas d'écritures concurentes 147 // 145 148 // Comme memoization, on ajoute une heure "histoire de pouvoir tourner 146 149 // sur le cache quand la base de donnees est plantée (à tester)" 147 // TODO CORE ? changer creer_cache pour qu'il appelle maj_invalideurs *avant* d'avoir écrit le cache148 150 $Memoization->set($fichier, $page, 3600+$duree); 149 151 } … … 155 157 // Exemple : <INCLURE{fond=mes_scores,duree-cache=#GET{duree_sicestmoi_oupas}}/> 156 158 if (isset($page['contexte']['duree-cache'])) { 157 if (!defined('LOG_ CACHELAB_DUREES_DYNAMIQUES') or LOG_CACHELAB_DUREES_DYNAMIQUES)158 spip_log ("Pour $fichier, contexte[duree-cache]={$page['contexte']['duree-cache']}", "cachelab");159 if (!defined('LOG_BALISECACHE_DUREES_DYNAMIQUES') or LOG_CACHELAB_DUREES_DYNAMIQUES) 160 spip_log ("Pour $fichier, contexte[duree-cache]={$page['contexte']['duree-cache']}", 'balisecache_duree_dynamique'); 159 161 160 162 if ($var_cache) … … 167 169 = intval($page['contexte']['duree-cache']); 168 170 171 // (idem : creer_cache appelle maj_invalideurs *aprés* d'avoir écrit le cache) 172 // 169 173 // Comme memoization, on ajoute une heure "histoire de pouvoir tourner 170 174 // sur le cache quand la base de donnees est plantée (à tester)" 171 // TODO CORE ? changer creer_cache pour qu'il appelle maj_invalideurs *avant* d'avoir écrit le cache172 175 $Memoization->set($fichier, $page, 3600+$duree); 173 176 } … … 178 181 list ($f, $arg) = split_first_arg($f); 179 182 if (function_exists($f)) { 180 if (!defined('LOG_ CACHELAB_FILTRES') or LOG_CACHELAB_FILTRES)181 spip_log ("#CACHE appelle le filtre $f ($arg)", "cachelab");183 if (!defined('LOG_BALISECACHE_FILTRES') or LOG_CACHELAB_FILTRES) 184 spip_log ("#CACHE appelle le filtre $f ($arg)", 'balisecache_filtres'); 182 185 $toset = $f($page, $arg); 183 186 // Le filtre renvoie un booléen qui indique s'il faut mémoizer le cache 184 187 if ($toset) 185 $Memoization->set($fichier, $page, $ cache['entete']['X-Spip-Cache']);188 $Memoization->set($fichier, $page, $page['entete']['X-Spip-Cache']); 186 189 } 187 190 else -
_plugins_/cachelab/trunk/paquet.xml
r113576 r115318 2 2 prefix="cachelab" 3 3 categorie="outil" 4 version="0. 12.1"4 version="0.99.0" 5 5 etat="dev" 6 compatibilite="[3.0.0;3. 2.*]"6 compatibilite="[3.0.0;3.3.*]" 7 7 logo="images/cachelab-32.png" 8 8 documentation="https://contrib.spip.net/5033" -
_plugins_/xray/trunk/cachelab_diag.php
r112521 r115318 62 62 63 63 $conditions = array('session'=>$session, 'chemin'=>$chemin, 'cle_objet'=>$cle_objet, 'id_objet'=>$id_objet, 'contexte'=>$contexte); 64 $options = array(' chrono'=>true, 'list'=>true, 'methode_chemin'=>$cachelab_methode_chemin);64 $options = array('list'=>true, 'methode_chemin'=>$cachelab_methode_chemin); 65 65 66 66 echo "<pre>" … … 81 81 $l_cible = $stats['l_cible']; 82 82 unset($stats['l_cible']); 83 $l_not_array = $stats['l_not_array'];84 unset($stats['l_not_array']);85 $l_no_data = $stats['l_no_data'];86 unset($stats['l_no_data']);87 83 88 84 echo "<h3>Bilan du filtrage</h3><br> … … 94 90 $joliecle 95 91 </a>"; 96 }97 98 if (count($l_not_array)) {99 echo "<h3>Erreurs d'accés (pas un tableau)</h3>100 <ul>";101 foreach ($l_not_array as $cle)102 echo "<li>".xray_lien_cache($cle)."</li>";103 echo "</ul>";104 92 } 105 93 -
_plugins_/xray/trunk/paquet.xml
r115041 r115318 2 2 prefix="xray" 3 3 categorie="outil" 4 version="0.23. 1"4 version="0.23.2" 5 5 etat="test" 6 compatibilite="[2.1.0;3. 2.*]"6 compatibilite="[2.1.0;3.3.*]" 7 7 logo="images/xray-32.png" 8 8 documentation="https://contrib.spip.net/4946" … … 22 22 <necessite nom="memoization"/> 23 23 <utilise nom="macrosession" /> 24 <utilise nom='cachelab' compatibilite="[0. 6.0;[" />24 <utilise nom='cachelab' compatibilite="[0.99.0;[" /> 25 25 </paquet> -
_plugins_/xray/trunk/plugin.xml
r115041 r115318 9 9 <licence>GPL</licence> 10 10 <licence>PHP</licence> 11 <version>0.23. 1</version>11 <version>0.23.2</version> 12 12 <etat>test</etat> 13 13 <description> … … 22 22 <url>xray</url> 23 23 </bouton> 24 <necessite id="SPIP" version="[2.1.0;3. 2.99]" />24 <necessite id="SPIP" version="[2.1.0;3.3.99]" /> 25 25 <necessite id="memoization" /> 26 26 <utilise id="macrosession" />
Note: See TracChangeset
for help on using the changeset viewer.