Funciones de APC

Tabla de contenidos

  • apc_add — Poner una nueva variable en caché en el almacén de datos
  • apc_bin_dump — Obtener una copia binaria de los ficheros y variables de usuario dados
  • apc_bin_dumpfile — Imprimir a un fichero una copia binaria de los ficheros y variables de usuario almacenados en caché
  • apc_bin_load — Cargar una copia binaria en la caché de archivo/usuario de APC
  • apc_bin_loadfile — Cargar una copia binaria desde un fichero a la caché de fichero/usuario de APC
  • apc_cache_info — Recupera información que hay en caché del almacén de datos de APC
  • apc_cas — Actualiza un valor anterior por un nuevo valor
  • apc_clear_cache — Limpia la caché de APC
  • apc_compile_file — Almacena un archivo en la caché de código de byte, evitando todos los filtros
  • apc_dec — Disminuye un número almacenado
  • apc_define_constants — Define un conjunto de constantes para recuperación y definición en masa
  • apc_delete_file — Borra archivos de la caché del código de operación
  • apc_delete — Elimina una variable almacenada de la caché
  • apc_exists — Comprobar si existe una clave de APC
  • apc_fetch — Traer una variable almacenada desde la caché
  • apc_inc — Aumentar un número almacenado
  • apc_load_constants — Carga un conjunto de constantes de la caché
  • apc_sma_info — Recupera la información de la Asignación de Memoria Compartida de APC
  • apc_store — Guardar una variable en caché en el almacén de datos
add a note add a note

User Contributed Notes 5 notes

zytzagoo at NOSPAMPLEASEgmail dot com
13 years ago
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.
joe at simpson dot com
13 years ago
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'
ashus at atlas dot cz
13 years ago
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.

if ((is_file($_SERVER['SCRIPT_FILENAME'].'.cached'))
    && (
time()-filemtime($_SERVER['SCRIPT_FILENAME'].'.cached') < 3600))

// (the php script itself goes here)

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


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.
13 years ago
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.
bjoern dot andersen at atosorigin dot com
13 years ago
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.
To Top