Tu crois qu’on ne pourrait pas ajouter une compatibilité avec APC ?
qq chose genre (pas encore testé) :
APC ?
elseif (function_exists(‹ apc_store ›)) {
function Cache($vars=null, $ttl=3600) {
$trace = debug_backtrace();
$trace = $trace[1];
$key = FILE . md5(
$trace[‹ function ›]
.serialize($trace[‹ args ›])
.serialize($vars)
);
if (!$cached = apc_fetch($key)) {
apc_store($key, null, $ttl);
$r = call_user_func_array($trace[‹ function ›], $trace[‹ args ›]);
apc_store($key, $r, $ttl);
return $r;
}
return $cached;
}
}
Je n’ai pas encore testé car il faut dire que je ne sais pas trop quelles fonctions de ecrire/public méritent d’etre mise en cache pour un résultat significatif (par contre j’ai « pour jouer » un serveur avec APC installé et qq gros SPIP)
.Gilles
On Tue, Oct 27, 2009 at 9:28 AM, <fil@rezo.net> wrote:
Author: fil@rezo.net
Date: Tue Oct 27 09:28:56 2009
New Revision: 32392Log:
plugin xcache base sur la fonction {{{W()}}} de http://zzz.rezo.net/Utiliser-xcache-pour-accelerer-n.htmlAdded:
plugins/xcache/
plugins/xcache/inc/
plugins/xcache/inc/xcache.php
plugins/xcache/plugin.xml
plugins/xcache/public/Added: plugins/xcache/inc/xcache.php
— plugins/xcache/inc/xcache.php (added)
+++ plugins/xcache/inc/xcache.php Tue Oct 27 09:28:56 2009
@@ -0,0 +1,42 @@
+<?php
+
+//
+// Cache function W()
+// (c) Fil 2009 - Double-licensed under the GNU/LGPL and MIT licenses
+// http://zzz.rezo.net/-SPIP-
+// $ttl = time to live
+// $vars = other variables that could change the result
+// (the function’s variables are automatically taken into account)
+//
+// Usage: require_once ‹ xcache.php ›;
+// In any cacheable function add at top: if (null!==$W=W())return$W;
+
+if (!function_exists(‹ W ›)) {
+
+# xcache ?
+if (function_exists(‹ xcache_set ›)) {
- function W($vars=null, $ttl=3600) {
- $trace = debug_backtrace();
- $trace = $trace[1];
- $key = FILE . md5(
- $trace[‹ function ›]
- .serialize($trace[‹ args ›])
- .serialize($vars)
- );
- if (!xcache_isset($key)) {
- xcache_set($key, null, $ttl);
- $r = call_user_func_array($trace[‹ function ›], $trace[‹ args ›]);
- xcache_set($key, $r, $ttl);
- return $r;
- }
- return xcache_get($key);
- }
+}
+# elementary compatibility
+else {- function W(){return null;}
+}+}
+
+?>Added: plugins/xcache/plugin.xml
— plugins/xcache/plugin.xml (added)
+++ plugins/xcache/plugin.xml Tue Oct 27 09:28:56 2009
@@ -0,0 +1,22 @@
+
- XCache
- Fil
- © 2009 - GNU/GPL
- 0.1
- dev
- Utilise XCache pour accelerer
- http://zzz.rezo.net/Utiliser-xcache-pour-accelerer-n.html
- XCache
- inc/xcache.php
+
Spip-zone-commit@rezo.net - http://listes.rezo.net/mailman/listinfo/spip-zone-commit