CakeFest 2024: The Official CakePHP Conference

Memcached::getStats

(PECL memcached >= 0.1.0)

Memcached::getStats获取服务器池的统计信息

说明

public Memcached::getStats(?string $type = null): array|false

Memcached::getStats() 返回一个包含所有可用 memcache 服务器状态的数组。 返回的统计信息的详细描述参见 » memcache 协议。 (译注:经实验,服务器池中有不可用服务器时,返回 false)

参数

type

要获取的统计的类型。

返回值

服务器统计信息数组,每个服务器一项, 或者在失败时返回 false

示例

示例 #1 Memcached::getStats() 示例

<?php
$m
= new Memcached();
$m->addServer('localhost', 11211);

print_r($m->getStats());
?>

以上示例的输出类似于:

Array
(
    [localhost:11211] => Array
        (
            [pid] => 4933
            [uptime] => 786123
            [threads] => 1
            [time] => 1233868010
            [pointer_size] => 32
            [rusage_user_seconds] => 0
            [rusage_user_microseconds] => 140000
            [rusage_system_seconds] => 23
            [rusage_system_microseconds] => 210000
            [curr_items] => 145
            [total_items] => 2374
            [limit_maxbytes] => 67108864
            [curr_connections] => 2
            [total_connections] => 151
            [connection_structures] => 3
            [bytes] => 20345
            [cmd_get] => 213343
            [cmd_set] => 2381
            [get_hits] => 204223
            [get_misses] => 9120
            [evictions] => 0
            [bytes_read] => 9092476
            [bytes_written] => 15420512
            [version] => 1.2.6
        )

)

add a note

User Contributed Notes 3 notes

up
0
billfeller at gmail dot com
10 years ago
the link to memcache protocol is out date. the new link is https://github.com/facebook/memcached/blob/master/doc/protocol.txt
up
0
ar knownat plista with com
14 years ago
The method currently does not support the optional (and subject to change) type parameter for the stats command:
- "items", "sizes", "slabs"

The documentation for the optional parameters can be found here (sections below General-purpose statistics):
http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt

The Memcache Extension can be uses to retrieve that information:
http://www.php.net/manual/en/function.memcache-getstats.php
To Top