10000 Introduce `Redis::OPT_PACK_IGNORE_NUMBERS` option. by michael-grunder · Pull Request #2616 · phpredis/phpredis · GitHub
[go: up one dir, main page]

Skip to content

Introduce Redis::OPT_PACK_IGNORE_NUMBERS option. #2616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add details to the option doc block
  • Loading branch information
michael-grunder committed Feb 5, 2025
commit 0ccd8f428925dc970978a1b37cac360c5390756d
19 changes: 19 additions & 0 deletions redis.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ class Redis {
* @var int
* @cvalue REDIS_OPT_PACK_IGNORE_NUMBERS
*
* When enabled, this option tells PhpRedis to ignore purely numeric values
* when packing and unpacking data. This does not include numeric strings.
* If you want numeric strings to be ignored, typecast them to an int or float.
*
* The primary purpose of this option is to make it more ergonomic when
* setting keys that will later be incremented or decremented.
*
* Note: This option incurs a small performance penalty when reading data
* because we have to see if the data is a string representation of an int
* or float.
*
* @example
* $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
* $redis->setOption(Redis::OPT_PACK_IGNORE_NUMBERS, true);
*
* $redis->set('answer', 32);
*
* var_dump($redis->incrBy('answer', 10)); // int(42)
* var_dump($redis->get('answer')); // int(42)
*/
public const OPT_PACK_IGNORE_NUMBERS = UNKNOWN;

Expand Down
2 changes: 1 addition & 1 deletion redis_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 78283cf59cefb411c09adf7a0f0bd234c65327b3 */
* Stub hash: 3c4051fdd9f860523bcd72aba260b1af823d1d9c */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null")
Expand Down
2 changes: 1 addition & 1 deletion redis_legacy_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 78283cf59cefb411c09adf7a0f0bd234c65327b3 */
* Stub hash: 3c4051fdd9f860523bcd72aba260b1af823d1d9c */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
ZEND_ARG_INFO(0, options)
Expand Down
Loading
0