pls aware of the get() function will change the content of your variable:
e.g.
$key = "this is a test";
$memcache->set($key, 1);
echo $memcache->get($key); // print out "1", as expected
echo $key; // print out "this_is_a_test"
i think you would like to use as the following:
$memcache->set("$key", 1);
echo $memcache->get("$key");