2

Ho to use memcache get_multi_async.

Doc says it returns "dictionary" of values. http://code.google.com/appengine/docs/python/memcache/clientclass.html#Client_get_multi_async

I was expecting it to return some kind of "async object" on which i can do get_result() later.

Am i missing something ??

Tiwari
  • 1,014
  • 2
  • 12
  • 22

2 Answers2

3

I believe you need to pass in an RPC object; the dictionary it speaks of will be obtained via the get_result() function on the RPC object.

bdonlan
  • 224,562
  • 31
  • 268
  • 324
1

The call to get_multi_async actually returns an RPC object which you use to later do the result.

client = memcache.Client()
rpc = client.get_multi_async(['key1', 'key2'])
# Do other work
result = rpc.get_result()

If you want, you can make your own RPC object which allows you to control the deadline and also provide a callback to be invoked when the fetch is finished:

client = memcache.Client()
rpc = memcache.create_rpc(deadline=30, callback=my_callback)
client.get_multi_async(['key1', 'key2'], rpc=rpc)

Note that the RPC object you make has to be from the memcache package, not the urlfetch one.

djd
  • 4,988
  • 2
  • 25
  • 35