'Ensure the given device is known; add it to the store if not
Args:
user_id (str): id of user associated with the device
device_id (str): id of device
initial_device_display_name (str): initial displayname of the
device. Ignored if device exists.
Returns:
defer.Deferred: boolean whether the device was inserted or an
existing device existed with that ID.'

@defer.inlineCallbacks
def store_device(self, user_id, device_id, initial_device_display_name):

    key = (user_id, device_id)
    if self.device_id_exists_cache.get(key, None):
        defer.returnValue(False)
    try:
        inserted = (yield self._simple_insert('devices', values={'user_id': user_id, 'device_id': device_id, 'display_name': initial_device_display_name}, desc='store_device', or_ignore=True))
        self.device_id_exists_cache.prefill(key, True)
        defer.returnValue(inserted)
    except Exception as e:
        logger.error('store_device    with    device_id=%s(%r)    user_id=%s(%r)    display_name=%s(%r)    failed:    %s', type(device_id).__name__, device_id, type(user_id).__name__, user_id, type(initial_device_display_name).__name__, initial_device_display_name, e)
        raise StoreError(500, 'Problem    storing    device.')
