PHP Velho Oeste 2024

apc_bin_dump

(PECL apc >= 3.1.4)

apc_bin_dumpПолучить бинарный дамп заданных файлов и пользовательских переменных

Описание

apc_bin_dump ([ array $files = NULL [, array $user_vars = NULL ]] ) : string

Возвращает бинарный дамп для заданных файлов и пользовательских переменных из кеша APC. Задайте NULL для файлов или пользовательских переменных для выгрузки всех объектов. Если передать пустой массив, то ничего не будет выгружено.

Список параметров

files

Список файлов. NULL для выгрузки всех записей. Пустой массив, если ничего выгружать не нужно.

user_vars

Пользовательские переменные. NULL для выгрузки всех записей. Пустой массив, если ничего выгружать не нужно.

Возвращаемые значения

Возвращает бинарный дамп для заданных файлов и пользовательских переменных из кеша APC, FALSE, если APC не включен, или NULL если встретилась неизвестная ошибка.

Смотрите также

  • apc_bin_dumpfile() - Вывести двоичный дамп кешированных файлов и пользовательских переменных в файл
  • apc_bin_load() - Загрузить бинарный дамп в файловый/пользовательский кеш APC
add a note add a note

User Contributed Notes 1 note

up
-2
mightye+php at gmail dot com
12 years ago
These items aren't clear to me from the documentation.

In order to store file opcodes (the first parameter), you MUST have apc.stat set to 0, and filenames passed into the first parameter MUST be absolute (full) paths.  Any other configuration will generate a warning and will not dump the files.  Also, apc.stat cannot be changed at runtime (so you can't do ini_set('apc.stat', 0) prior to executing the apc_bin_dump* functions), it must be set in php.ini (or otherwise defined prior to execution of your script; for example for PHP CLI you can do "php -d apc.stat=0"). 

The files passed to apc_bin_dump*() must already exist in the opcode cache; you should do apc_compile_file() on any filenames you're not certain will be in the cache already (best practice is to do it for all files to be certain they are up to date since the mandatory apc.stat=0 disables checking whether the files are up to date, but apc_compile_file() will always refresh the file's cache).

When doing apc_bin_load*(), you do not have to have apc.stat=0, but failing to have this value may overwrite your restored value with a newly created opcode from the file on the disk if anything attempts to include that file again (even other scripts at a later time).

If you're intending to just store variables (not file opcodes), you don't have to have apc.stat=0, but you will still get a warning about apc.stat not being the correct value, even if the first parameter is an empty array() or null.

The format for the $user_vars parameter is array('varname1',..,'varnameN').  The values which are stored come out of the APC data store (not the local variable scope, nor can these be values which are passed into this function).  You must first apc_store() any value you wish to persist with these functions.  Likewise, these variables are restored to the APC data store by apc_bin_load*() rather than the local scope or as a return value in some form. 

So if your intent is to store a local variable for later use, first apc_store('varname', $varname) (assuming you have no collisions with other scopes using the same 'varname') before calling apc_bin_dump*().  When restoring, you'll need to do $varname = apc_fetch('varname') after calling apc_bin_load*()
To Top