Repository navigation
[apcu] Clarify apcu_fetch() behaviour when an array of keys is given - #60
Open
officialasishkumar wants to merge 2 commits into
Open
officialasishkumar wants to merge 2 commits into
officialasishkumar wants to merge 2 commits into
Conversation
jordikroon
requested changes
Nov 28, 2026
jordikroon
left a comment
Member
There was a problem hiding this comment.
Thank you. This looks great. Some minor nits to clarify things a bit better.
Comment on lines
+29
to
+31
| <function>apcu_store</function>). If an array of keys is passed then | ||
| each key is fetched, and the entries which are found in the cache are | ||
| returned as an array. |
Member
There was a problem hiding this comment.
Suggested change
| <function>apcu_store</function>). If an array of keys is passed then | |
| each key is fetched, and the entries which are found in the cache are | |
| returned as an array. | |
| <function>apcu_store</function>). If an array of keys is passed then | |
| each key is fetched, and the entries which are found in the cache are | |
| returned as an array. Array elements that are not strings are skipped | |
| and an <constant>E_WARNING</constant> is raised. |
Contributor
Author
There was a problem hiding this comment.
Added the note about non-string elements being skipped with an E_WARNING in 3bcebfe.
Comment on lines
+50
to
+51
| If <parameter>key</parameter> is a string, returns the stored value on | ||
| success, or &false; on failure. |
Member
There was a problem hiding this comment.
Suggested change
| If <parameter>key</parameter> is a string, returns the stored value on | |
| success, or &false; on failure. | |
| If <parameter>key</parameter> is a string, returns the stored value, or | |
| &false; if the key does not exist in the cache or has expired. |
Contributor
Author
There was a problem hiding this comment.
Applied, the return value now says it's false when the key doesn't exist or has expired. Done in 3bcebfe.
The return values section described the result as "the stored variable or array of variables", which suggested that apcu_fetch() would somehow create variables, and did not explain what is actually returned for an array of keys. Document the behaviour as implemented in php_apc.c: - when key is an array, an associative array mapping each key found in the cache to its value is returned, and missing keys are omitted; - in that case the success parameter is always set to true, even if none of the keys exist; - since false can be stored as a value, success is the way to tell a stored false apart from a failure. Also type the key parameter as string|array instead of mixed, matching the extension stub, describe the function in terms of values rather than variables, and add an example fetching several entries at once and destructuring the result. Fixes php#19
Mention that non-string elements of an array of keys are skipped with an E_WARNING, and state that a string key returns false when the entry does not exist in the cache or has expired.
officialasishkumar
force-pushed
the
fix/apcu-fetch-array-keys
branch
from
November 28, 2026 18:58
c3f826e to
3bcebfe
Compare
jordikroon
approved these changes
Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
apcu_fetch()page described the return value as "the stored variable or array of variables". That wording suggests the function sets variables, and it doesn't explain what you get back when you pass an array of keys.This change documents what
php_apc.cactually does:keyis an array, the function returns an associative array that maps each key found in the cache to its value. Keys that aren't in the cache are left out of the result.successis always set totrue, even if none of the keys exist.falsecan be stored as a value, a note explains thatsuccessis how you tell a storedfalseapart from a failure.It also:
keyasstring|arrayinstead ofmixed, matching the extension stub;Fixes #19