Invalidate cache on device deletion

This commit is contained in:
Erik Johnston 2017-05-08 15:55:59 +01:00
parent fc6d4974a6
commit 94e6ad71f5
1 changed files with 6 additions and 2 deletions

View File

@ -115,12 +115,14 @@ class DeviceStore(SQLBaseStore):
Returns: Returns:
defer.Deferred defer.Deferred
""" """
return self._simple_delete_one( self._simple_delete_one(
table="devices", table="devices",
keyvalues={"user_id": user_id, "device_id": device_id}, keyvalues={"user_id": user_id, "device_id": device_id},
desc="delete_device", desc="delete_device",
) )
self.device_id_exists_cache.invalidate((user_id, device_id))
def delete_devices(self, user_id, device_ids): def delete_devices(self, user_id, device_ids):
"""Deletes several devices. """Deletes several devices.
@ -130,13 +132,15 @@ class DeviceStore(SQLBaseStore):
Returns: Returns:
defer.Deferred defer.Deferred
""" """
return self._simple_delete_many( self._simple_delete_many(
table="devices", table="devices",
column="device_id", column="device_id",
iterable=device_ids, iterable=device_ids,
keyvalues={"user_id": user_id}, keyvalues={"user_id": user_id},
desc="delete_devices", desc="delete_devices",
) )
for device_id in device_ids:
self.device_id_exists_cache.invalidate((user_id, device_id))
def update_device(self, user_id, device_id, new_display_name=None): def update_device(self, user_id, device_id, new_display_name=None):
"""Update a device. """Update a device.