Does app engine’s “memcache.get()” return a reference or deep copy?
The reason I ask is because I’d like to know if I need to call memcache.set() after I’ve modified an object.
For example:
# INITALIZE
t_var = {}
t_var['foo'] = 1
memcache.set('some_key', t_var)
# LATER ON...
t_var = memcache.get('some_key')
t_var['foo'] = 2
# EVEN LATER ON...
t_var = memcache.get('some_key')
print t_var['foo']
Is does print t-var['foo'] display a ‘1’ or a ‘2’?
Objects are serialized (using
pickleby default) before being sent tomemcached. Thus, the objects you get back are necessarily copies. This is becausememcachedis a separate process from the Python interpreter and, furthermore, knows nothing of Python objects specifically.