Skip to content

feat: Update get method documentation and handle non-existent cache keys in Redis driver - #84

Open
madwings wants to merge 4 commits into
pocketarc:developfrom
madwings:feat/redis
Open

madwings wants to merge 4 commits into
pocketarc:developfrom
madwings:feat/redis

Conversation

@madwings

@madwings madwings commented Nov 2, 2026 •

Copy link
Copy Markdown

This is a suggestion about get() behaviour in 3.2-dev. 3.1 returned an empty string if the value set was NULL or FALSE and returned FALSE if the key did not exist, so there was a way to distinguish existing and non-existing keys. With the change made in 3.2-dev this distinction cannot be made. It now returns FALSE for bool(false) and for non-existing keys. It makes much more sense to return NULL if the key is non-existent or settype() fails. Also settype() throws an exception in PHP 8.0+( which also supports the NULL return type), which most of the people will use nowadays or with this repo.

This pull request makes small but important changes to the Cache_redis driver to improve its return value consistency and documentation. The main focus is on ensuring that the get method consistently returns NULL instead of FALSE when a cache entry is missing or cannot be properly converted, and on updating the method's documentation to reflect possible exceptions.

  • Return value consistency:

    • Changed the get method to return NULL instead of FALSE when a cache entry is missing, cannot be converted, or when the type is unsupported, aligning with typical PHP caching expectations.
  • Documentation improvements:

    • Updated the @return annotation in the get method's docblock to clarify that NULL is returned if the key does not exist or type conversion fails, and added an @throws annotation for ValueError in PHP 8+.

@madwings madwings changed the title fix: Update get method documentation and handle non-existent cache keys in Redis driver feat: Update get method documentation and handle non-existent cache keys in Redis driver Nov 2, 2026
Updated the return type documentation for the get method to clarify possible return values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant