downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

apc_add> <Constantes pré-définies
[edit] Last updated: Fri, 10 Feb 2012

view this page in

Fonctions APC

Sommaire

  • apc_add — Met en cache une variable dans le magasin de données
  • apc_bin_dump — Récupère une sortie binaire des fichiers fournis et des variables utilisateur
  • apc_bin_dumpfile — Envoi une sortie binaire des fichiers fournis et des variables utilisateur vers un fichier spécifique
  • apc_bin_load — Charge une sortie binaire dans le cache fichiers ou utilisateur d'APC
  • apc_bin_loadfile — Charge une sortie binaire depuis un fichier dans le cache fichiers ou utilisateur d'APC
  • apc_cache_info — Récupère les informations du cache dans l'entrepôt APC
  • apc_cas — Met à jour une ancienne valeur par une nouvelle
  • apc_clear_cache — Efface le cache APC
  • apc_compile_file — Stocke un fichier dans le cache, en évitant tous les filtres
  • apc_dec — Décrémente un nombre stocké
  • apc_define_constants — Définit un jeu de constantes pour la récupération et la définition en masse
  • apc_delete_file — Efface un fichier depuis le cache opcode
  • apc_delete — Efface une variable stockée dans le cache
  • apc_exists — Vérifie si une clé APC existe
  • apc_fetch — Récupère une variable stockée dans le cache
  • apc_inc — Incrémente un nombre stocké
  • apc_load_constants — Charge un jeu de constantes depuis le cache
  • apc_sma_info — Récupère les informations d'allocation mémoire partagée d'APC
  • apc_store — Met en cache une variable dans le magasin


apc_add> <Constantes pré-définies
[edit] Last updated: Fri, 10 Feb 2012
 
add a note add a note User Contributed Notes Fonctions APC
mike at eastghost dot com 06-Feb-2012 04:18
I've been testing Memcache and Memcached extensions versus storing and fetching data to/from APC.  No scientifics or hard numbers yet, but APC seems to be noticeably faster.  One drawback appears to be if APC fills, it seems to flush everything alive beyond TTL in a huge purge.
joe at simpson dot com 20-Sep-2007 04:53
It seems there are issues when using APC to cache database result sets as PDOStatements. Any attempts I have made always result in an exception being thrown with the message: 'You cannot serialize or unserialize PDOStatement instances'
zytzagoo at NOSPAMPLEASEgmail dot com 30-Jul-2007 06:21
Keep in mind to always prefix or suffix your cache key names with something specific to your site/app/setup, to avoid the risk of your apc cache entries being overwritten/deleted/modified by someone else on the same server.

Assume we have some code like this:

<?php apc_store('config', $cfg); ?>

Now assume someone else on the same server is also using 'config' as the key passed to an apc_store(), apc_delete() (etc.) call in some other piece of code on the whole server.

Since you're both working on the exact same cache entry, all sorts of wierd things can happen, but the problem is not in your code at all.
anon 03-Jul-2007 12:28
If you don't want any APC info visible without logging in, insert this code at line 173 of apc.php:

<?php

if (!$AUTHENTICATED) {
    echo
'<div class="authneeded">You need to login to see the user values here!<br/>&nbsp;<br/>';
   
put_login_link("Login now!");
    echo
'</div>';
    die();
}

?>
bjoern dot andersen at atosorigin dot com 23-May-2007 08:14
In IIS6 you can't use php_apc.dll with application pools or webgardens (Multi-Instance/Multi-Threading). Maybe this applies even to all Multithreading environments - i don't know.

When you try it, the Application pools terminate when requests run simultaneously.
ashus at atlas dot cz 21-Mar-2007 06:56
If you don't really need caching and plan to use it for one page only, you could try an alternative; writing a file and then flushing it back if specified time hasn't passed. I use it to read and parse third party websites, to check for new subtitles and output a RSS xml file.

<?php
if ((is_file($_SERVER['SCRIPT_FILENAME'].'.cached'))
    && (
time()-filemtime($_SERVER['SCRIPT_FILENAME'].'.cached') < 3600))
    {
   
readfile($_SERVER['SCRIPT_FILENAME'].'.cached');
    exit;
    }

// (the php script itself goes here)

echo $out;
$fp = fopen($_SERVER['SCRIPT_FILENAME'].'.cached', 'w');
fwrite($fp, $out);
fclose($fp);

?>

Note, that this only works for pages, which are without GET or POST variables, sessions, etc. You can change the number of seconds the cache works for (3600 = an hour). Also, use "$out.=" instead of "echo" command. Just store all output to that variable (if you need to use it inside a function, use "global $out" instead).
This workaround was written in about 5 minutes and may contain bugs.
dustymugs 30-Jan-2007 06:14
In windows, if you load php_apc.dll but do not enable it, apache may crash when attempting to restart or stop.

So, if you've not enabled APC but are loading it, comment out the loading.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites