-1

I'm running phpredis version 2.2.5 on an Amazon Linux EC2 server, and for a while was fiddling around in the console talking to Redis and everything was working fine.

Then, I plug in the PHP and start trying to have my code talk to the DB and that's when the trouble starts--every single value I add gets prepended with odd text, but the keys are okay.

I input the following code:

function subscribe($type,$value,$user) {
try {
    $redis = newRedis();

    $redis -> set("sub:$type:$value:$user","true");     

    $redis -> close();
} catch (Exception $e) {
    $redis -> close();
    return false;
}

}

with the goal of getting a key-value like "sub:chat:1:1" => "true". What I get instead is "sub:chat:1:1" => "s:4:\"true\";" when I read the redis DB in my console. What is going on here that it keeps changing this? I initially thought it was because I was passing integers to be the values, so I switched up the whole structure to pass text strings as a test, but the problem is still here.

random
  • 9,774
  • 10
  • 66
  • 83
Brenton H
  • 31
  • 2
  • If you intent to set a logical true, you would not quote the value. However, the string is getting serialized. If you do `serialize("true")` you will see the same result. – datasage Jun 02 '14 at 04:50
  • Datasage--that was it! I had left on a line turning on serialization earlier and forgotten to deactivate it. Thanks so much for your help! – Brenton H Jun 02 '14 at 12:45

1 Answers1

0

Check your code for any string lying outside the php tags. I tried the same code on my local and it works smoothly and gives expected result.

Chhavi Gangwal
  • 1,166
  • 9
  • 13
  • Thanks for your help, Chhavi. You were right--it was outside the code. Datasage's comment above led to to go routing around and I saw that I was serializing all my value data. – Brenton H Jun 02 '14 at 12:52