I am trying to share my memcache server with my rails and php server.
Rails:
my_var = {'one'=>1,'two'=>2}
Rails.cache.write 'hello', PHP.serialize(my_var), :raw => true
Rails.cache.read 'hello'
output:
"a:2:{s:3:\"one\";i:1;s:3:\"two\";i:2;}"
PHP:
$var = self::$memcache->get('hello');
die(var_dump($var));
output:
"a:2:{s:3:\"one\";i:1;s:3:\"two\";i:2;}"
PHP.serialize is a function from gem php_serialize.
I was hoping that my PHP server can pickup hello and produces an array. Could anyone please help me which part that I do wrong here?
Thank you
Memcached gives back the serialized (marshaled) string. To use the actual array, you need to unserialize it in PHP first, just like you have to serialize the array in Ruby.
Try