def get_multi(self, keys, key_prefix='<STR_LIT>'):
self._statlog('<STR_LIT>')<EOL>server_keys, prefixed_to_orig_key = self._map_and_prefix_keys(keys, key_prefix)<EOL>dead_servers = []<EOL>for server in server_keys.keys():<EOL><INDENT>try:<EOL><INDENT>server.send_cmd("<STR_LIT>" % "<STR_LIT:U+0020>".join(server_keys[server]))<EOL><DEDENT>except socket.error as msg:<EOL><INDENT>if isinstance(msg, tuple): msg = msg[<NUM_LIT:1>]<EOL>server.mark_dead(msg)<EOL>dead_servers.append(server)<EOL><DEDENT><DEDENT>for server in dead_servers:<EOL><INDENT>del server_keys[server]<EOL><DEDENT>retvals = {}<EOL>for server in server_keys.keys():<EOL><INDENT>try:<EOL><INDENT>line = server.readline()<EOL>while line and line != '<STR_LIT>':<EOL><INDENT>rkey, flags, rlen = self._expectvalue(server, line)<EOL>if rkey is not None:<EOL><INDENT>val = self._recv_value(server, flags, rlen)<EOL>retvals[prefixed_to_orig_key[rkey]] = val   <EOL><DEDENT>line = server.readline()<EOL><DEDENT><DEDENT>except (_Error, socket.error) as msg:<EOL><INDENT>if isinstance(msg, tuple): msg = msg[<NUM_LIT:1>]<EOL>server.mark_dead(msg)<EOL><DEDENT><DEDENT>return retvals<EOL>
Retrieves multiple keys from the memcache doing just one query.

>>> success = mc.set("foo", "bar")
>>> success = mc.set("baz", 42)
>>> mc.get_multi(["foo", "baz", "foobar"]) == {"foo": "bar", "baz": 42}
1
>>> mc.set_multi({'k1' : 1, 'k2' : 2}, key_prefix='pfx_') == []
1

This looks up keys 'pfx_k1', 'pfx_k2', ... . Returned dict will just have unprefixed keys 'k1', 'k2'.
>>> mc.get_multi(['k1', 'k2', 'nonexist'], key_prefix='pfx_') == {'k1' : 1, 'k2' : 2}
1

get_mult [ and L{set_multi} ] can take str()-ables like ints / longs as keys too. Such as your db pri key fields.
They're rotored through str() before being passed off to memcache, with or without the use of a key_prefix.
In this mode, the key_prefix could be a table name, and the key itself a db primary key number.

>>> mc.set_multi({42: 'douglass adams', 46 : 'and 2 just ahead of me'}, key_prefix='numkeys_') == []
1
>>> mc.get_multi([46, 42], key_prefix='numkeys_') == {42: 'douglass adams', 46 : 'and 2 just ahead of me'}
1

This method is recommended over regular L{get} as it lowers the number of
total packets flying around your network, reducing total latency, since
your app doesn't have to wait for each round-trip of L{get} before sending
the next one.

See also L{set_multi}.

@param keys: An array of keys.
@param key_prefix: A string to prefix each key when we communicate with memcache.
    Facilitates pseudo-namespaces within memcache. Returned dictionary keys will not have this prefix.
@return:  A dictionary of key/value pairs that were available. If key_prefix was provided, the keys in the retured dictionary will not have it present.