'Set multiple keys with a specified policy.
Helper function for set_multi(), add_multi(), and replace_multi(). This
reduces the network latency of doing many requests in serial.
Args:
policy:  One of MemcacheSetRequest.SET, .ADD, .REPLACE or .CAS.
mapping: Dictionary of keys to values.  If policy == CAS, the
values must be (value, cas_id) tuples.
time: Optional expiration time, either relative number of seconds
from current time (up to 1 month), or an absolute Unix epoch time.
By default, items never expire, though items may be evicted due to
memory pressure.  Float values will be rounded up to the nearest
whole second.
key_prefix: Prefix for to prepend to all keys.
namespace: a string specifying an optional namespace to use in
the request.
Returns:
A list of keys whose values were NOT set.  On total success,
this list should be empty.  On network/RPC/server errors,
a list of all input keys is returned; in this case the keys
may or may not have been updated.'

def _set_multi_with_policy(self, policy, mapping, time=0, key_prefix='', namespace=None):

    rpc = self._set_multi_async_with_policy(policy, mapping, time, key_prefix, namespace)
    status_dict = rpc.get_result()
    (server_keys, user_key) = rpc.user_data
    if (not status_dict):
        return user_key.values()
    unset_list = []
    for server_key in server_keys:
        key = user_key[server_key]
        set_status = status_dict[key]
        if (set_status != MemcacheSetResponse.STORED):
            unset_list.append(key)
    return unset_list
