略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: apc_bin_dumpfile

2024-12-23

apc_bin_dumpfile

(PECL apc >= 3.1.4)

apc_bin_dumpfileOutput a binary dump of cached files and user variables to a file

说明

apc_bin_dumpfile ( array $files , array $user_vars , string $filename [, int $flags = 0 [, resource $context = NULL ]] ) : int

Outputs a binary dump of the given files and user variables from the APC cache to the named file.

参数

files

The file names being dumped.

user_vars

The user variables being dumped.

filename

The filename where the dump is being saved.

flags

Flags passed to the filename stream. See the file_put_contents() documentation for details.

context

The context passed to the filename stream. See the file_put_contents() documentation for details.

返回值

The number of bytes written to the file, otherwise FALSE if APC is not enabled, filename is an invalid file name, filename can't be opened, the file dump can't be completed (e.g., the hard drive is out of disk space), or an unknown error was encountered.

参见

add a note add a note

User Contributed Notes 1 note

up
2
eric at midkotasolutions dot com
8 years ago
To prevent losing all of your APC custom user data on an apache restart, use this function along with apc_bin_loadfile to save your APC Memory Data on a restart of apache.

e.g.  Write a php script to dump the file and one to re-load the file.   Call the dump script directly before stopping apache, and then call the reload script directly after starting apache.

<?php
//saveapc
     
apc_bin_dumpfile(array(),null,"/path/to/my/file.data");
?>

<?php
//loadapc
    
apc_bin_loadfile("/path/to/my/file.data");
?>

#  wget http://www.example.com/saveapc.php
# /etc/init.d/httpd restart
#  wget http://www.example.com/loadapc.php

Particularly useful if you have a custom session handler using APC for storage

Even more handy, update the httpd restart bash script to automatically make these calls for you on a restart

官方地址:https://www.php.net/manual/en/function.apc-bin-dumpfile.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3