Using set more than once for the same key seems to have unexpected results - it does not behave as a "replace," but instead seems to "set" more than one value for the same key. "get" may return any of the values.
This was tested on a multiple-server setup - behaviour may be different if you only have one server.
Remedy is to use a combination of replace and set:
<?php
$result = $memcache->replace( $key, $var );
if( $result == false )
{
$result = $memcache->set( $key, $var );
}
?>