Max
Max

Reputation:

Accessing a PHP-set memcache key from Python

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?

Upvotes: 1

Views: 1083

Answers (2)

PedroMorgan
PedroMorgan

Reputation: 926

You could serialise the "data" into json, which I've done once.

Upvotes: 1

Frank Farmer
Frank Farmer

Reputation: 39356

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.

Upvotes: 4

Related Questions