Q: Google app engine serialization issue I want to store bigML Model object in memcache. Following below steps.
1- serialize a bigML Model object
2- store the serialize string in memcache.
3- fetch serialize string from memcache.
4- unserialize the string.
$local_model = new Model($latestModel, $api);
$local_model_obj = serialize($local_model);
$memcache->set('latest_model_object',$local_model_obj);
$local_model = unserialize($local_model_obj);

Note: serialization and unserialization are working fine in my local server. and in server it is throwing below error.
unserialize(): Error at offset 100 of 3726 bytes in /base..
Screenshot: http://prnt.sc/byzzai


A: Vaishnavesh, 
This might be an issue with different encoding versions between your local server and remote servers. Anyway, try to check if using base64 encoding helps:
$local_model_obj = base64_encode(serialize($local_model));
...
$local_model = unserialize(base64_decode($local_model_obj));

Check this other answer: Change serialization functions in PHP for Memcached 

A: $local_model_obj = serialize($local_model);
$specialChar = before ('ass"', after ('";O:8:"', $local_model_obj));
$local_model_obj = str_replace($specialChar, 'stdCl', $local_model_obj);
$local_model = unserialize($local_model_obj);

function after ($this, $inthat)
{
    if (!is_bool(strpos($inthat, $this)))
    return substr($inthat, strpos($inthat,$this)+strlen($this));
};
function before ($this, $inthat)
{
    return substr($inthat, 0, strpos($inthat, $this));
};

It is working fine. but I think it is not a valid way.
