Search code examples
phpserializationredisphp-7phpredis

adding a set of integers to Redis using phpredis


I am trying to add a SET of integers (sadd) via PHPRedis extension.

 $Client->sadd('key',1,2,3);

or
call_user_func_array([$Client,'sadd'],[1,2,3]);

In the monitor I get:

"SADD" "key" "i:1" "i:2" "i:3"`  

Which means it is serialized.
How do I do it so it is not serialized and inserted into Redis like if I do it from command line.
Monitor:

"SADD" "key" "1" "2" "3"

Solution

  • Seems it was some negligence on my part.
    In my connection I set by default

    $Redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
    

    So all I have to do is use in the connection code (which is the default)

    $Redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE)