views:

239

answers:

1

I'm storing a value in memcached using PHP's Memcache extension and trying to retrieve it in a daemon written in Python sitting behind my webapp. But, it keeps returning None or throwing "local variable 'val' referenced before assignment".

I'm sure I'm looking for the same key, and there's only one mc server available to either app (localhost). If I try setting the key on a Python terminal, it returns False and unsets it (i.e., I can no longer retrieve it through PHP). Any ideas?

+3  A: 

By default, the PHP client stores keys in PHP's serialized format (which Python won't understand by default). If the Python client does something similar (using its own serialization format), that'd be your problem.

You can always use telnet/netcat to see what exactly is getting stored.

Frank Farmer
Checking over telnet shows that the key is set properly, but the flag value is "768," which I can't figure out how to interpret. It looks like that, or something relating to that, is what's confusing python-memcached.