Browse Source

device service cache eviction fix for saveDeviceWithCredentials

pull/5082/head
Sergey Matvienko 5 years ago
parent
commit
ecca0e5df3
  1. 8
      dao/src/main/java/org/thingsboard/server/dao/device/DeviceServiceImpl.java

8
dao/src/main/java/org/thingsboard/server/dao/device/DeviceServiceImpl.java

@ -207,7 +207,10 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe
return doSaveDevice(device, null, true);
}
@CacheEvict(cacheNames = DEVICE_CACHE, key = "{#device.tenantId, #device.name}")
@Caching(evict= {
@CacheEvict(cacheNames = DEVICE_CACHE, key = "{#device.tenantId, #device.name}"),
@CacheEvict(cacheNames = DEVICE_CACHE, key = "{#device.tenantId, #device.id}")
})
@Override
public Device saveDeviceWithCredentials(Device device, DeviceCredentials deviceCredentials) {
if (device.getId() == null) {
@ -631,7 +634,7 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe
throw new ProvisionFailedException(ProvisionResponseStatus.FAILURE.name());
}
}
removeDeviceFromCacheById(savedDevice.getTenantId(), savedDevice.getId());
removeDeviceFromCacheById(savedDevice.getTenantId(), savedDevice.getId()); // eviction by name is described as annotation @CacheEvict above
return savedDevice;
}
@ -721,6 +724,7 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe
}
if (!old.getName().equals(device.getName())) {
removeDeviceFromCacheByName(tenantId, old.getName());
removeDeviceFromCacheById(tenantId, device.getId());
}
}

Loading…
Cancel
Save