Reputation: 87
When I store the value of the memcache key "show-errors" with value true using the following method call it returns success (ie. true) saying it has set.
$memcacheObj->set("show-errors", true);
But when I get the key using the following method call I get 1 instead of true
$memcacheObj->get($key);
Can anyone help me with this. I need to get the value exactly as stored in the memcache.
I have cross verified that my memcached server is running on my local system using the following method it returns true.
$this->cacheObj->connect('127.0.0.1', '11211');
Upvotes: 0
Views: 210
Reputation: 37358
Unlike what you've been told in the comments, the unserialized value of a serialized boolean TRUE is still true. It seems the problem is not your memcache but your check.
Try checking weather your variable is === true
rather than printing it out and you'll see.
Here's some example code to show you how this works:
<?php
$peter = true;
$serPeter = serialize($peter);
$unserPeter = unserialize($serPeter);
if($unserPeter === TRUE) {
echo 'TRUE';
}
elseif($unserPeter === 1) {
echo '1';
}
else {
echo '$unserPeter is : ('.$unserPeter.')';
}
Upvotes: 1