From cd66fc9fce70d10b4cd7531ad4f7aa0c803b5579 Mon Sep 17 00:00:00 2001 From: "singi.qin" Date: Thu, 30 Apr 2026 09:36:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E7=BF=BB=E8=AF=91=20appendices\exa?= =?UTF-8?q?mples.xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appendices/examples.xml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 appendices/examples.xml diff --git a/appendices/examples.xml b/appendices/examples.xml new file mode 100644 index 000000000..2469053b0 --- /dev/null +++ b/appendices/examples.xml @@ -0,0 +1,32 @@ + + + + + 关于手册示例 + + 需要注意的是,为了清晰简洁,PHP 文档中的许多示例都省略了错误和异常处理。 + + + 这并不意味着生产环境代码可以省略错误处理,因为此举可能会引发 TypeError 错误、强制转换失败值(例如将布尔值 &false; 转为空字符串),或是违背代码预设逻辑,进而产生难以排查的隐蔽漏洞。部分扩展库提供了完整示例,其中均包含错误处理逻辑,用以演示该扩展所提供各类函数与方法的规范用法。 + + + From f8b6637d5433d72c05109a8e2b84fcaa96cdeb5a Mon Sep 17 00:00:00 2001 From: "singi.qin" Date: Thu, 30 Apr 2026 17:52:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E7=BF=BB=E8=AF=91=20apcu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot --- reference/apcu/apcuiterator/construct.xml | 111 ++++++ reference/apcu/apcuiterator/current.xml | 61 ++++ reference/apcu/apcuiterator/gettotalcount.xml | 65 ++++ reference/apcu/apcuiterator/gettotalhits.xml | 65 ++++ reference/apcu/apcuiterator/gettotalsize.xml | 65 ++++ reference/apcu/apcuiterator/key.xml | 61 ++++ reference/apcu/apcuiterator/next.xml | 62 ++++ reference/apcu/apcuiterator/rewind.xml | 61 ++++ reference/apcu/apcuiterator/valid.xml | 61 ++++ reference/apcu/constants.xml | 239 +++++++++++++ reference/apcu/functions/apcu-cas.xml | 128 +++++++ reference/apcu/functions/apcu-clear-cache.xml | 61 ++++ reference/apcu/functions/apcu-dec.xml | 145 ++++++++ reference/apcu/functions/apcu-delete.xml | 97 +++++ reference/apcu/functions/apcu-enabled.xml | 53 +++ reference/apcu/functions/apcu-entry.xml | 161 +++++++++ reference/apcu/functions/apcu-exists.xml | 121 +++++++ reference/apcu/functions/apcu-fetch.xml | 125 +++++++ reference/apcu/functions/apcu-inc.xml | 144 ++++++++ reference/apcu/functions/apcu-key-info.xml | 109 ++++++ reference/apcu/functions/apcu-sma-info.xml | 111 ++++++ reference/apcu/ini.xml | 338 ++++++++++++++++++ reference/apcu/setup.xml | 72 ++++ 23 files changed, 2516 insertions(+) create mode 100644 reference/apcu/apcuiterator/construct.xml create mode 100644 reference/apcu/apcuiterator/current.xml create mode 100644 reference/apcu/apcuiterator/gettotalcount.xml create mode 100644 reference/apcu/apcuiterator/gettotalhits.xml create mode 100644 reference/apcu/apcuiterator/gettotalsize.xml create mode 100644 reference/apcu/apcuiterator/key.xml create mode 100644 reference/apcu/apcuiterator/next.xml create mode 100644 reference/apcu/apcuiterator/rewind.xml create mode 100644 reference/apcu/apcuiterator/valid.xml create mode 100644 reference/apcu/constants.xml create mode 100644 reference/apcu/functions/apcu-cas.xml create mode 100644 reference/apcu/functions/apcu-clear-cache.xml create mode 100644 reference/apcu/functions/apcu-dec.xml create mode 100644 reference/apcu/functions/apcu-delete.xml create mode 100644 reference/apcu/functions/apcu-enabled.xml create mode 100644 reference/apcu/functions/apcu-entry.xml create mode 100644 reference/apcu/functions/apcu-exists.xml create mode 100644 reference/apcu/functions/apcu-fetch.xml create mode 100644 reference/apcu/functions/apcu-inc.xml create mode 100644 reference/apcu/functions/apcu-key-info.xml create mode 100644 reference/apcu/functions/apcu-sma-info.xml create mode 100644 reference/apcu/ini.xml create mode 100644 reference/apcu/setup.xml diff --git a/reference/apcu/apcuiterator/construct.xml b/reference/apcu/apcuiterator/construct.xml new file mode 100644 index 000000000..7e46644db --- /dev/null +++ b/reference/apcu/apcuiterator/construct.xml @@ -0,0 +1,111 @@ + + + + + + APCUIterator::__construct + 构造 APCUIterator 迭代器对象 + + + + &reftitle.description; + + public APCUIterator::__construct + arraystringnullsearch&null; + intformatAPC_ITER_ALL + intchunk_size100 + intlistAPC_LIST_ACTIVE + + + 构造一个 APCUIterator object。 + + + + + &reftitle.parameters; + + + search + + + 可以是与 APCu 键名匹配的 PCRE 正则表达式,作为 &string; 提供。 + 也可以是包含 APCu 键名的 &string; 数组。 + 也可以是 &null;,以跳过搜索。 + + + + + format + + + 所需的格式,通过一个或多个 + APC_ITER_* 常量配置。 + + + + + chunk_size + + + 块大小。必须大于 0。默认值为 100。 + + + + + list + + + 要列出的类型。传入 APC_LIST_ACTIVE + 或 APC_LIST_DELETED。 + + + + + + + + &reftitle.examples; + + <function>APCUIterator::__construct</function> 示例 + + +]]> + + + + + + &reftitle.seealso; + + apcu_exists + apcu_cache_info + + + + + diff --git a/reference/apcu/apcuiterator/current.xml b/reference/apcu/apcuiterator/current.xml new file mode 100644 index 000000000..519c11b5e --- /dev/null +++ b/reference/apcu/apcuiterator/current.xml @@ -0,0 +1,61 @@ + + + + + + APCUIterator::current + 获取当前条目 + + + + &reftitle.description; + + public mixedAPCUIterator::current + + + + 从 APCUIterator 堆栈获取当前条目。 + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + 成功时返回当前条目;如果没有更多条目或失败,则返回 &false;。 + + + + + &reftitle.seealso; + + APCUIterator::next + Iterator::current + + + + + diff --git a/reference/apcu/apcuiterator/gettotalcount.xml b/reference/apcu/apcuiterator/gettotalcount.xml new file mode 100644 index 000000000..bb5d09dec --- /dev/null +++ b/reference/apcu/apcuiterator/gettotalcount.xml @@ -0,0 +1,65 @@ + + + + + + APCUIterator::getTotalCount + 获取总数 + + + + &reftitle.description; + + public intAPCUIterator::getTotalCount + + + + 获取总数。 + + + &warn.undocumented.func; + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + 总数。 + + + + + &reftitle.seealso; + + APCUIterator::getTotalHits + APCUIterator::getTotalSize + apcu_cache_info + + + + + diff --git a/reference/apcu/apcuiterator/gettotalhits.xml b/reference/apcu/apcuiterator/gettotalhits.xml new file mode 100644 index 000000000..e61d27fd5 --- /dev/null +++ b/reference/apcu/apcuiterator/gettotalhits.xml @@ -0,0 +1,65 @@ + + + + + + APCUIterator::getTotalHits + 获取缓存总命中数 + + + + &reftitle.description; + + public intAPCUIterator::getTotalHits + + + + 获取缓存命中的总次数。 + + + &warn.undocumented.func; + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + 成功时返回命中次数,失败时返回 &false;。 + + + + + &reftitle.seealso; + + APCUIterator::getTotalCount + APCUIterator::getTotalSize + apcu_cache_info + + + + + diff --git a/reference/apcu/apcuiterator/gettotalsize.xml b/reference/apcu/apcuiterator/gettotalsize.xml new file mode 100644 index 000000000..6bba3e33b --- /dev/null +++ b/reference/apcu/apcuiterator/gettotalsize.xml @@ -0,0 +1,65 @@ + + + + + + APCUIterator::getTotalSize + 获取缓存总大小 + + + + &reftitle.description; + + public intAPCUIterator::getTotalSize + + + + 获取缓存总大小。 + + + &warn.undocumented.func; + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + 缓存总大小。 + + + + + &reftitle.seealso; + + APCUIterator::getTotalCount + APCUIterator::getTotalHits + apc_cache_info + + + + + diff --git a/reference/apcu/apcuiterator/key.xml b/reference/apcu/apcuiterator/key.xml new file mode 100644 index 000000000..492217b95 --- /dev/null +++ b/reference/apcu/apcuiterator/key.xml @@ -0,0 +1,61 @@ + + + + + + APCUIterator::key + 获取迭代器键 + + + + &reftitle.description; + + public stringAPCUIterator::key + + + + 获取当前迭代器键。 + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + 成功时返回键,失败时返回 &false;。 + + + + + &reftitle.seealso; + + APCUIterator::current + Iterator::key + + + + + diff --git a/reference/apcu/apcuiterator/next.xml b/reference/apcu/apcuiterator/next.xml new file mode 100644 index 000000000..d93990174 --- /dev/null +++ b/reference/apcu/apcuiterator/next.xml @@ -0,0 +1,62 @@ + + + + + + APCUIterator::next + 将指针移动到下一个条目 + + + + &reftitle.description; + + public boolAPCUIterator::next + + + + 将迭代器指针移动到下一个元素。 + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + &return.success; + + + + + &reftitle.seealso; + + APCUIterator::current + APCUIterator::rewind + Iterator::next + + + + + diff --git a/reference/apcu/apcuiterator/rewind.xml b/reference/apcu/apcuiterator/rewind.xml new file mode 100644 index 000000000..f42e112ae --- /dev/null +++ b/reference/apcu/apcuiterator/rewind.xml @@ -0,0 +1,61 @@ + + + + + + APCUIterator::rewind + 回退迭代器 + + + + &reftitle.description; + + public voidAPCUIterator::rewind + + + + 将迭代器回退到第一个元素。 + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.seealso; + + APCUIterator::next + Iterator::next + + + + + diff --git a/reference/apcu/apcuiterator/valid.xml b/reference/apcu/apcuiterator/valid.xml new file mode 100644 index 000000000..ffda4b3bb --- /dev/null +++ b/reference/apcu/apcuiterator/valid.xml @@ -0,0 +1,61 @@ + + + + + + APCUIterator::valid + 检查当前位置是否有效 + + + + &reftitle.description; + + public boolAPCUIterator::valid + + + + 检查当前迭代器位置是否有效。 + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + 如果当前迭代器位置有效则返回 &true;,否则返回 &false;。 + + + + + &reftitle.seealso; + + APCUIterator::current + Iterator::valid + + + + + diff --git a/reference/apcu/constants.xml b/reference/apcu/constants.xml new file mode 100644 index 000000000..714e63733 --- /dev/null +++ b/reference/apcu/constants.xml @@ -0,0 +1,239 @@ + + + + + + &reftitle.constants; + &extension.constants; + + + + + APC_ITER_ALL + (int) + + + + 所有字段。 + + + + + + APC_ITER_ATIME + (int) + + + + 访问时间。 + + + + + + APC_ITER_CTIME + (int) + + + + 创建时间。 + + + + + + APC_ITER_DEVICE + (int) + + + + 设备。 + + + + + + APC_ITER_DTIME + (int) + + + + 删除时间。 + + + + + + APC_ITER_FILENAME + (int) + + + + 文件名。 + + + + + + APC_ITER_INODE + (int) + + + + inode。 + + + + + + APC_ITER_KEY + (int) + + + + 键。 + + + + + + APC_ITER_MD5 + (int) + + + + MD5 哈希。 + + + + + + APC_ITER_MEM_SIZE + (int) + + + + 内存大小。 + + + + + + APC_ITER_MTIME + (int) + + + + 修改时间。 + + + + + + APC_ITER_NONE + (int) + + + + 无。 + + + + + + APC_ITER_NUM_HITS + (int) + + + + 命中次数。 + + + + + + APC_ITER_REFCOUNT + (int) + + + + 引用计数。 + + + + + + APC_ITER_TTL + (int) + + + + TTL。 + + + + + + APC_ITER_TYPE + (int) + + + + 类型。 + + + + + + APC_ITER_VALUE + (int) + + + + 值。 + + + + + + APC_LIST_ACTIVE + (int) + + + + 活动列表。 + + + + + + APC_LIST_DELETED + (int) + + + + 删除列表。 + + + + + diff --git a/reference/apcu/functions/apcu-cas.xml b/reference/apcu/functions/apcu-cas.xml new file mode 100644 index 000000000..ed7669222 --- /dev/null +++ b/reference/apcu/functions/apcu-cas.xml @@ -0,0 +1,128 @@ + + + + + + apcu_cas + 用新值更新旧值 + + + + &reftitle.description; + + boolapcu_cas + stringkey + intold + intnew + + + 如果 old 参数与当前存储值匹配,apcu_cas + 将使用 new 参数的值更新已存在的整数值。 + + + + + &reftitle.parameters; + + + key + + + 要更新的值的键。 + + + + + old + + + 旧值(当前存储的值)。 + + + + + new + + + 要更新的新值。 + + + + + + + + + &reftitle.returnvalues; + + &return.success; + + + + + &reftitle.examples; + + <function>apcu_cas</function> 示例 + + +]]> + + &example.outputs.similar; + + + + + + + + &reftitle.seealso; + + apcu_dec + apcu_store + + + + + diff --git a/reference/apcu/functions/apcu-clear-cache.xml b/reference/apcu/functions/apcu-clear-cache.xml new file mode 100644 index 000000000..3e6162b55 --- /dev/null +++ b/reference/apcu/functions/apcu-clear-cache.xml @@ -0,0 +1,61 @@ + + + + + + apcu_clear_cache + + 清除 APCu 缓存 + + + + &reftitle.description; + + boolapcu_clear_cache + + + + 清除缓存。 + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + 始终返回 &true; + + + + + &reftitle.seealso; + + apcu_cache_info + + + + + diff --git a/reference/apcu/functions/apcu-dec.xml b/reference/apcu/functions/apcu-dec.xml new file mode 100644 index 000000000..9d33489f4 --- /dev/null +++ b/reference/apcu/functions/apcu-dec.xml @@ -0,0 +1,145 @@ + + + + + + apcu_dec + 减少已存储的数字 + + + + &reftitle.description; + + intfalseapcu_dec + stringkey + intstep1 + boolsuccess + intttl0 + + + 减少已存储的整数值。 + + + + + &reftitle.parameters; + + + key + + + 要递减的值的键。 + + + + + step + + + 递减的步长或减去的值。 + + + + + success + + + 可选地将成功或失败的布尔值传递到此引用变量。 + + + + + ttl + + + 如果该操作插入新值(而不是递减现有值),则使用的 TTL。 + + + + + + + + &reftitle.returnvalues; + + 成功时返回 key 的当前值;失败时返回 &return.falseforfailure;。 + + + + + &reftitle.examples; + + <function>apcu_dec</function> example + + +]]> + + &example.outputs.similar; + + + + + + + + + &reftitle.seealso; + + apcu_inc + + + + + diff --git a/reference/apcu/functions/apcu-delete.xml b/reference/apcu/functions/apcu-delete.xml new file mode 100644 index 000000000..82cdb6f63 --- /dev/null +++ b/reference/apcu/functions/apcu-delete.xml @@ -0,0 +1,97 @@ + + + + + + apcu_delete + + 从缓存中移除已存储的变量 + + + + &reftitle.description; + + mixedapcu_delete + mixedkey + + + 从缓存中移除已存储的变量。 + + + + &reftitle.parameters; + + + key + + + key 可以是一个字符串,用于表示单个键, + 也可以是一个字符串数组,表示多个键, + 或者是一个 APCUIterator 对象。 + + + + + + + &reftitle.returnvalues; + + 如果 key 是一个 &array;,则返回键的索引 &array;。 + 否则,成功时返回 &true;,失败时返回 &false;。 + + + + + &reftitle.examples; + + A <function>apcu_delete</function> example + + +]]> + + + + + + &reftitle.seealso; + + apcu_store + apcu_fetch + apcu_clear_cache + APCUIterator + + + + + diff --git a/reference/apcu/functions/apcu-enabled.xml b/reference/apcu/functions/apcu-enabled.xml new file mode 100644 index 000000000..e5d5ac0fc --- /dev/null +++ b/reference/apcu/functions/apcu-enabled.xml @@ -0,0 +1,53 @@ + + + + + + apcu_enabled + APCu 在当前环境中是否可用 + + + + &reftitle.description; + + boolapcu_enabled + + + + 返回 APCu 在当前环境中是否可用。 + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + Returns &true; when APCu is usable in the current environment, &false; otherwise. + + + + + diff --git a/reference/apcu/functions/apcu-entry.xml b/reference/apcu/functions/apcu-entry.xml new file mode 100644 index 000000000..de89ac54e --- /dev/null +++ b/reference/apcu/functions/apcu-entry.xml @@ -0,0 +1,161 @@ + + + + + + apcu_entry + + 原子地获取或生成缓存条目 + + + + &reftitle.description; + + mixedapcu_entry + stringkey + callablecallback + intttl0 + + + 原子性地尝试在缓存中查找 key,如果未找到,则调用 callback, + 并将 key 作为唯一参数传入。调用的返回值随后使用可选指定的 + ttl 进行缓存,并返回。 + + + + 进入 apcu_entry 时,会独占地获取缓存锁;离开 apcu_entry 时释放该锁。 + 这实际上将 callback 的主体变为一个临界区,禁止两个进程并发执行相同的代码路径。 + 此外,它还禁止任何其他 APCu 函数并发执行,因为它们将获取相同的锁。 + + + + + callback 中唯一可以安全调用的 APCu 函数是 apcu_entry。 + + + + + &reftitle.parameters; + + + key + + + 缓存条目的标识。 + + + + + callback + + + 一个可调用函数,该函数接受 key 作为唯一参数并返回要缓存的值。 + + + + + ttl + + + 生存时间;将 callback 的返回值缓存 + ttl 秒。经过 + ttl 后,存储的条目将在下一次请求时从缓存中移除。 + 如果未提供 ttl(或 ttl + 为 0),则该值将一直保留,直到手动从缓存中移除,或因其他原因在缓存中不存在(清除、重启等)。 + + + + + + + &reftitle.returnvalues; + + 返回缓存的值。 + + + + + &reftitle.examples; + + An <function>apcu_entry</function> example + + apcu_entry("config.fruit", function($key){ + return [ + "apples", + "pears" + ]; + }), + "people" => apcu_entry("config.people", function($key){ + return [ + "bob", + "joe", + "niki" + ]; + }) + ]; +}); + +var_dump($config); +?> +]]> + + &example.outputs; + + + array(2) { + [0]=> + string(6) "apples" + [1]=> + string(5) "pears" + } + ["people"]=> + array(3) { + [0]=> + string(3) "bob" + [1]=> + string(3) "joe" + [2]=> + string(4) "niki" + } +} +]]> + + + + + + &reftitle.seealso; + + apcu_store + apcu_fetch + apcu_delete + + + + + diff --git a/reference/apcu/functions/apcu-exists.xml b/reference/apcu/functions/apcu-exists.xml new file mode 100644 index 000000000..f428ccc65 --- /dev/null +++ b/reference/apcu/functions/apcu-exists.xml @@ -0,0 +1,121 @@ + + + + + + apcu_exists + 检查条目是否存在 + + + + &reftitle.description; + + boolarrayapcu_exists + stringarraykeys + + + 检查一个或多个 APCu 条目是否存在。 + + + + + &reftitle.parameters; + + + keys + + + 一个字符串,或者一个字符串数组,用于包含键。 + + + + + + + + &reftitle.returnvalues; + + 如果键存在,则返回 &true;,否则返回 &false;。如果传入的是一个 + array,则返回一个包含所有存在键的数组;如果没有键存在,则返回空数组。 + + + + + &reftitle.examples; + + <function>apcu_exists</function> example + + +]]> + + &example.outputs.similar; + + + bool(true) + ["bar"]=> + bool(true) +} +]]> + + + + + + &reftitle.seealso; + + apcu_cache_info + apcu_fetch + + + + diff --git a/reference/apcu/functions/apcu-fetch.xml b/reference/apcu/functions/apcu-fetch.xml new file mode 100644 index 000000000..b6f5873a3 --- /dev/null +++ b/reference/apcu/functions/apcu-fetch.xml @@ -0,0 +1,125 @@ + + + + + + apcu_fetch + + 从缓存中获取已存储的变量 + + + + &reftitle.description; + + mixedapcu_fetch + mixedkey + boolsuccess + + + 从缓存中获取一个条目。 + + + + &reftitle.parameters; + + + key + + + 用于存储值的 key(通过 + apcu_store)。如果传入一个数组,则会获取并返回 + 每个元素的值。 + + + + + success + + + 成功时设为 &true;,失败时设为 &false;。 + + + + + + + &reftitle.returnvalues; + + 成功时返回存储的变量或变量数组;失败时返回 &false;。 + + + + + &reftitle.changelog; + + + + + &Version; + &Description; + + + + + PECL apcu 3.0.17 + + The success parameter was added. + + + + + + + + + &reftitle.examples; + + A <function>apcu_fetch</function> example + + +]]> + + &example.outputs; + + + + + + + + &reftitle.seealso; + + apcu_store + apcu_delete + APCUIterator + + + + + diff --git a/reference/apcu/functions/apcu-inc.xml b/reference/apcu/functions/apcu-inc.xml new file mode 100644 index 000000000..220122585 --- /dev/null +++ b/reference/apcu/functions/apcu-inc.xml @@ -0,0 +1,144 @@ + + + + + + apcu_inc + 增加已存储的数字 + + + + &reftitle.description; + + intfalseapcu_inc + stringkey + intstep1 + boolsuccess + intttl0 + + + 增加已存储的数字。 + + + + + &reftitle.parameters; + + + key + + + 要递增的值的键。 + + + + + step + + + 递增的步长或增加的值。 + + + + + success + + + 可选地将成功或失败的布尔值传递到此引用变量。 + + + + + ttl + + + 如果该操作插入新值(而不是递增现有值),则使用的 TTL。 + + + + + + + + &reftitle.returnvalues; + + 成功时返回 key 的当前值,失败时返回 &return.falseforfailure;。 + + + + + &reftitle.examples; + + <function>apcu_inc</function> example + + +]]> + + &example.outputs.similar; + + + + + + + + &reftitle.seealso; + + apcu_dec + + + + + diff --git a/reference/apcu/functions/apcu-key-info.xml b/reference/apcu/functions/apcu-key-info.xml new file mode 100644 index 000000000..8f5d404dc --- /dev/null +++ b/reference/apcu/functions/apcu-key-info.xml @@ -0,0 +1,109 @@ + + + + + + apcu_key_info + + 获取有关缓存键的详细信息 + + + + + &reftitle.description; + + arraynullapcu_key_info + stringkey + + + 获取有关缓存键的详细信息。 + + + + + &reftitle.parameters; + + + key + + + 获取有关缓存键的详细信息。 + + + + + + + + &reftitle.returnvalues; + + 包含有关缓存键的详细信息的数组;如果键不存在,则返回 &null;。 + + + + + &reftitle.examples; + + A <function>apcu_key_info</function> example + + +]]> + + &example.outputs; + + + int(0) + ["access_time"]=> + int(1606701783) + ["mtime"]=> + int(1606701783) + ["creation_time"]=> + int(1606701783) + ["deletion_time"]=> + int(0) + ["ttl"]=> + int(0) + ["refs"]=> + int(0) +} +]]> + + + + + + &reftitle.seealso; + + apcu_store + apcu_fetch + apcu_delete + + + + + diff --git a/reference/apcu/functions/apcu-sma-info.xml b/reference/apcu/functions/apcu-sma-info.xml new file mode 100644 index 000000000..46bcb24ae --- /dev/null +++ b/reference/apcu/functions/apcu-sma-info.xml @@ -0,0 +1,111 @@ + + + + + + apcu_sma_info + + 检索 APCu 共享内存分配信息 + + + + &reftitle.description; + + arrayfalseapcu_sma_info + boollimited&false; + + + 检索 APCu 共享内存分配信息。 + + + + + &reftitle.parameters; + + + limited + + + 当设置为 &false;(默认)时,apcu_sma_info 将返回每个内存段的详细信息。 + + + + + + + + &reftitle.returnvalues; + + 共享内存分配数据的数组;失败时返回 &false;。 + + + + + &reftitle.examples; + + A <function>apcu_sma_info</function> example + + +]]> + + &example.outputs.similar; + + 1 + [seg_size] => 31457280 + [avail_mem] => 31448408 + [block_lists] => Array + ( + [0] => Array + ( + [0] => Array + ( + [size] => 31448408 + [offset] => 8864 + ) + + ) + + ) + +) +]]> + + + + + + &reftitle.seealso; + + + APCu configuration directives + + + + + + diff --git a/reference/apcu/ini.xml b/reference/apcu/ini.xml new file mode 100644 index 000000000..22c25e5cf --- /dev/null +++ b/reference/apcu/ini.xml @@ -0,0 +1,338 @@ + + + +
+ &reftitle.runtime; + &extension.runtime; + + 虽然默认的 APCu 设置对许多安装来说都很好,但认真的用户应该考虑调整以下参数。 + + + 配置 APCu 时需要做一个决定。 + 要为 APCu 分配多少内存。 + 控制此的 ini 指令是 apc.shm_size + 请仔细阅读下面的相关部分。 + + + 一旦服务器运行,扩展包中捆绑的 apc.php 脚本应该被复制到 docroot 中的某个位置, + 并在浏览器中查看,因为它提供了 APCu 内部工作机制的详细分析。如果在 PHP 中启用了 GD,它甚至会显示一些有趣的图表。 + + 如果 APCu 正在工作,Cache full count + 数字(在左侧)将显示缓存达到最大容量并必须驱逐条目以释放内存的次数。 + 在驱逐期间,如果指定了 apc.ttl,APCu 将首先尝试移除过期的条目,即 TTL 已过期或没有设置 TTL 且在最后 + apc.ttl 秒内未被访问的条目。如果未设置 apc.ttl, + 或者移除过期条目没有释放足够的空间,APCu 将清除整个缓存。 + + + 在配置良好的缓存中,驱逐次数应该最小。如果缓存不断被填满,从而被迫释放,结果的翻腾将对脚本性能产生负面影响。 + 最小化此数字的最简单方法是为 APCu 分配更多内存。 + + + 当 APCu 使用 mmap 支持(内存映射)编译时,它将只使用一个内存段, + 与使用 SHM(SysV 共享内存)支持构建 APCu 时使用多个内存段不同。 + MMAP 没有像 SHM 在 /proc/sys/kernel/shmmax 中的最大限制。 + 一般来说,推荐使用 MMAP 支持,因为它会在 Web 服务器重启时更快地回收内存,并且总体上减少启动时的内存分配影响。 + + + + APCu 配置选项 + + + + &Name; + &Default; + &Changeable; + &Changelog; + + + + + apc.enabled + 1 + INI_SYSTEM + + + + apc.shm_segments + 1 + INI_SYSTEM + + + + apc.shm_size + "32M" + INI_SYSTEM + + + + apc.entries_hint + 512 * apc.shm_size + INI_SYSTEM + Prior to APcu 5.1.25, the default was 4096 + + + apc.ttl + 0 + INI_SYSTEM + + + + apc.gc_ttl + 3600 + INI_SYSTEM + + + + apc.mmap_file_mask + NULL + INI_SYSTEM + + + + apc.slam_defense + 0 + INI_SYSTEM + + + + apc.enable_cli + 0 + INI_SYSTEM + + + + apc.use_request_time + 0 + INI_ALL + Prior to APCu 5.1.19, the default was 1. + + + apc.serializer + "php" + INI_SYSTEM + Prior to APCu 5.1.15, the default was "default". + + + apc.coredump_unmap + 0 + INI_SYSTEM + + + + apc.preload_path + NULL + INI_SYSTEM + + + + +
+ &ini.php.constants; +
+ + &ini.descriptions.title; + + + + + apc.enabled + bool + + + + apc.enabled 可以设置为 0 来禁用 APC。这主要在 APC 静态编译到 PHP 中时有用, + 因为没有其他方法来禁用它(当作为 DSO 编译时,php.ini 中的 extension + 行可以被注释掉)。 + + + + + + apc.shm_segments + int + + + + 要为编译器缓存分配的共享内存段的数量。 + 如果 APC 耗尽了共享内存但 apc.shm_size + 已设置为系统允许的最大值,则提高此值可能会阻止 APC 耗尽其内存。 + + + + + + apc.shm_size + string + + + + 每个共享内存段的大小,使用如此 FAQ 中描述的简写表示法。 + 默认情况下,一些系统(包括大多数 BSD 变体)对共享内存段的大小有非常低的限制。 + + + + + + apc.entries_hint + int + + + + 关于可能存储的不同变量数量的“提示”。 + 如果不确定,请设置为零或省略。 + + + + + + apc.ttl + int + + + + 如果没有显式 TTL 的缓存条目在此秒数内未被访问,则认为它们已过期。 + 有效地,这允许在缓存插入期间或在完全清除之前机会性地移除此类条目。 + 请注意,由于移除是机会性的,即使条目比 apc.ttl 秒更旧,它们仍然可以读取。 + 此设置对具有显式 TTL 的缓存条目没有影响。 + + + + + + apc.gc_ttl + int + + + + 缓存条目在被移除或失效后可以在垃圾回收列表上保留的秒数。 + 如果它们的引用计数为零,或者超过此时间限制,则条目有资格被移除。 + 如果设置为 0,则禁用基于时间的清理, + 并且仅在引用计数降至零时移除条目。 + + + + + + apc.mmap_file_mask + string + + + + 如果使用 --enable-mmap 编译时启用了 MMAP 支持, + 这是传递给 mmap 模块的 mktemp 风格 file_mask,用于确定您的 mmap 内存区域是文件支持还是共享内存支持。 + 对于直接文件支持的 mmap,将其设置为类似 /tmp/apc.XXXXXX + 的内容(正好 6 个 X)。 + 要使用 POSIX 风格的 shm_open/mmap,请在您的掩码中放置 .shm。 + 例如 /apc.shm.XXXXXX + 您也可以将其设置为 /dev/zero 以使用您的内核的 /dev/zero 接口进行匿名 mmap 内存。 + 保持未定义将强制匿名 mmap。 + + + + + + apc.slam_defense + bool + + + + 在非常繁忙的服务器上,每当您启动服务器或修改文件时,您可以创建许多进程同时尝试缓存同一文件的竞争。 + 将 apc.slam_defense 设置为 1 + 可以通过引入概率机制来帮助防止多个进程同时缓存同一文件。 + 如果在短时间内由不同进程尝试缓存相同的键,则跳过当前进程的缓存以减轻潜在的缓存冲击。 + + + + + + apc.enable_cli + int + + + + 主要用于测试和调试。设置此项为 CLI 版本的 PHP 启用 APC。 + 在正常情况下,在每个 CLI 请求上创建、填充和销毁 APC 缓存并不是理想的, + 但对于各种测试场景,能够轻松为 CLI 版本的 PHP 启用 APC 是有用的。 + + + + + + apc.serializer + string + + + + 用于配置 APC 使用第三方序列化器。 + + + + + + apc.coredump_unmap + bool + + + + 启用 APC 处理信号,例如 SIGSEGV,这些信号在被信号触发时写入核心文件。 + 当接收到这些信号时,APC 将尝试取消映射共享内存段,以将其从核心文件中排除。 + 当配置了大的 APC 共享内存段时,此设置可能会提高系统稳定性。 + + + + 此功能可能很危险。在致命信号处理程序中取消映射共享内存段可能会导致未定义的行为,如果发生致命错误。 + + + + + 虽然某些内核可能提供在生成核心转储文件时忽略各种类型的共享内存的功能, + 但这些实现也可能忽略重要的共享内存段,例如 Apache 记分板。 + + + + + + + apc.preload_path + string + + + + 可选地,设置 APC 在启动时加载缓存数据的目录路径。 + + + + + + + apc.use_request_time + bool + + + + 使用 SAPI 请求开始时间作为 TTL。 + + + + +
+ diff --git a/reference/apcu/setup.xml b/reference/apcu/setup.xml new file mode 100644 index 000000000..abeffc9ac --- /dev/null +++ b/reference/apcu/setup.xml @@ -0,0 +1,72 @@ + + + + + &reftitle.setup; + +
+ &reftitle.install; + + &pecl.info; + &url.pecl.package;apcu. + + + + PHP 7 有一个单独的模块(apcu-bc)用于与 APC 的向后兼容。 + + + 在向后兼容模式下,APCu 使用向后兼容的原型注册适用的 APC 函数。 + + + 在 APC 函数接受 cache_type, it is simply + 它被向后兼容版本简单忽略,并在 APCu 版本的原型中省略。 + + + + + 从 PHP 8.0.0 开始,apcu-bc 不再受支持。 + + + + + 在 Windows 上,APCu 需要一个临时路径存在,并且可被 Web 服务器写入。 + 它按 TMP、TEMP 和 USERPROFILE 环境变量的顺序检查, + 如果都没有设置,则最后尝试 WINDOWS 目录。 + + + + + 有关更深入、高度技术性的实现细节,请参见 + + 开发者提供的 TECHNOTES 文件 + 。 + + + + APCu 源代码可以在这里找到。 + +
+ + &reference.apcu.ini; + +
+