Skip to content
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

Setting the integer values with serializer/compression, does not work with increments #2373

Open
2 tasks done
bmtKIA6 opened this issue Aug 17, 2023 · 2 comments
Open
2 tasks done

Comments

@bmtKIA6
Copy link

bmtKIA6 commented Aug 17, 2023

Expected behaviour

Same output whether compression/serializer is enabled or disabled.
Running the code with the defaults, works.
With compression/serializer in any permutation, does not work.

<?php
error_reporting(E_ALL);

ini_set('display_errors', 1);
ini_set("output_buffering", "off");
ini_set("max_execution_time", -1);

header("Content-type: text/plain");

echo PHP_VERSION . PHP_EOL;


$redis = new Redis();
$redis->connect('redis', 6379);
//$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
//$redis->setOption(Redis::OPT_COMPRESSION, Redis::COMPRESSION_LZ4);

assert($redis->ping());


$key = "int_key_42";

var_dump($redis->set($key, 42));
var_dump($redis->getLastError());
var_dump($redis->get($key));
var_dump($redis->getLastError());
var_dump($redis->incr($key, 42));
var_dump($redis->getLastError());
var_dump($redis->get($key));
var_dump($redis->getLastError());

output

7.4.33
bool(true)
NULL
string(2) "42"
NULL
int(84)
NULL
string(2) "84"
NULL

enable compression/serializer

<?php
error_reporting(E_ALL);

ini_set('display_errors', 1);
ini_set("output_buffering", "off");
ini_set("max_execution_time", -1);

header("Content-type: text/plain");

echo PHP_VERSION . PHP_EOL;


$redis = new Redis();
$redis->connect('redis', 6379);
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
$redis->setOption(Redis::OPT_COMPRESSION, Redis::COMPRESSION_LZ4);

assert($redis->ping());


$key = "int_key_42";

var_dump($redis->set($key, 42));
var_dump($redis->getLastError());
var_dump($redis->get($key));
var_dump($redis->getLastError());
var_dump($redis->incr($key, 42));
var_dump($redis->getLastError());
var_dump($redis->get($key));
var_dump($redis->getLastError());

output

7.4.33
bool(true)
NULL
int(42)
NULL
bool(false)
string(44) "ERR value is not an integer or out of range�"
int(42)
string(44) "ERR value is not an integer or out of range�"

Actual behaviour

I'm seeing this behaviour on

  • OS: Ubuntu 22.04 and 20.04
  • Redis: 7.0.11
  • PHP: 8.1.2 / 7.4.33
  • phpredis: 5.3.7

Steps to reproduce, backtrace or example script

I've checked

  • There is no similar issue from other users
  • Issue isn't fixed in develop branch
@bmtKIA6
Copy link
Author

bmtKIA6 commented Sep 28, 2023

@yatsukhnenko is this an expected behavior?

Should we be creating wrappers and have checks with is_numeric and disabling the compression/serialization?

@michael-grunder
Copy link
Member

Should we be creating wrappers and have checks with is_numeric and disabling the compression/serialization?**

You could do that or use a distinct object for serverside operations like INCR.

The reason it's not a bug is that INCR and DECR happen entirely on the server, and an igbinary serialized number won't look like a number to Redis, so it will just return an error.

There's not really anything we can do about that on our end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants