PHP 8.1.28 Released!

apcu_cache_info

(PECL apcu >= 4.0.0)

apcu_cache_info 从 APCu 存储中获取缓存信息

说明

apcu_cache_info(bool $limited = false): array|false

从 APCu 存储中获取缓存信息和元数据(meta-data)。

参数

limited

如果 limitedtrue,则不会返回具体被缓存的数据的列表,这在尝试根据统计数据进行调用优化时是很有用的。

返回值

成功时返回包含缓存数据(和元数据)的数组 或者在失败时返回 false

注意: apcu_cache_info() 无法获取到缓存信息时会触发警告(warning),这种情况通常是因为没有开启 APC 功能。

更新日志

版本 说明
PECL apcu 3.0.11 引入了 limited 参数。
PECL apcu 3.0.16 cache_type 参数增加了 "filehits" 选项。

示例

示例 #1 apcu_cache_info() 示例

<?php
print_r
(apcu_cache_info());
?>

以上示例的输出类似于:

Array
(
    [num_slots] => 2000
    [ttl] => 0
    [num_hits] => 9
    [num_misses] => 3
    [start_time] => 1123958803
    [cache_list] => Array
        (
            [0] => Array
                (
                    [filename] => /path/to/apcu_test.php
                    [device] => 29954
                    [inode] => 1130511
                    [type] => file
                    [num_hits] => 1
                    [mtime] => 1123960686
                    [creation_time] => 1123960696
                    [deletion_time] => 0
                    [access_time] => 1123962864
                    [ref_count] => 1
                    [mem_size] => 677
                )
            [1] => Array (...依次列出每个缓存文件)
)

参见

add a note

User Contributed Notes 1 note

up
0
RQuadling at GMail dot com
1 year ago
If you get the following warning when using APCu functions via PHP's CLI SAPI:

PHP Warning: apcu_cache_info(): No APC info available. Perhaps APC is not enabled? Check apc.enabled in your ini file

then check the status of `apc.enable_cli`. This is a separate INI entry for enabling APC via the CLI SAPI.
To Top