|
|
@ -55,6 +55,7 @@ public class DeviceCacheManagerImpl implements DeviceCacheManager {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addDeviceToCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId) {
|
|
|
|
public void addDeviceToCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId) {
|
|
|
|
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
|
|
|
|
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
|
|
|
|
|
|
|
|
if (lCache != null) {
|
|
|
|
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
|
|
|
|
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
|
|
|
|
if (lCache.containsKey(cacheKey)) {
|
|
|
|
if (lCache.containsKey(cacheKey)) {
|
|
|
|
this.updateDeviceInCache(deviceIdentifier, device, tenantId);
|
|
|
|
this.updateDeviceInCache(deviceIdentifier, device, tenantId);
|
|
|
@ -62,40 +63,50 @@ public class DeviceCacheManagerImpl implements DeviceCacheManager {
|
|
|
|
lCache.put(cacheKey, device);
|
|
|
|
lCache.put(cacheKey, device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void removeDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId) {
|
|
|
|
public void removeDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId) {
|
|
|
|
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
|
|
|
|
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
|
|
|
|
|
|
|
|
if (lCache != null) {
|
|
|
|
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
|
|
|
|
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
|
|
|
|
if (lCache.containsKey(cacheKey)) {
|
|
|
|
if (lCache.containsKey(cacheKey)) {
|
|
|
|
lCache.remove(cacheKey);
|
|
|
|
lCache.remove(cacheKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void removeDevicesFromCache(List<DeviceCacheKey> deviceList) {
|
|
|
|
public void removeDevicesFromCache(List<DeviceCacheKey> deviceList) {
|
|
|
|
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
|
|
|
|
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
|
|
|
|
|
|
|
|
if (lCache != null) {
|
|
|
|
for (DeviceCacheKey cacheKey : deviceList) {
|
|
|
|
for (DeviceCacheKey cacheKey : deviceList) {
|
|
|
|
if (lCache.containsKey(cacheKey)) {
|
|
|
|
if (lCache.containsKey(cacheKey)) {
|
|
|
|
lCache.remove(cacheKey);
|
|
|
|
lCache.remove(cacheKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateDeviceInCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId) {
|
|
|
|
public void updateDeviceInCache(DeviceIdentifier deviceIdentifier, Device device, int tenantId) {
|
|
|
|
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
|
|
|
|
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
|
|
|
|
|
|
|
|
if (lCache != null) {
|
|
|
|
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
|
|
|
|
DeviceCacheKey cacheKey = getCacheKey(deviceIdentifier, tenantId);
|
|
|
|
if (lCache.containsKey(cacheKey)) {
|
|
|
|
if (lCache.containsKey(cacheKey)) {
|
|
|
|
lCache.replace(cacheKey, device);
|
|
|
|
lCache.replace(cacheKey, device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Device getDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId) {
|
|
|
|
public Device getDeviceFromCache(DeviceIdentifier deviceIdentifier, int tenantId) {
|
|
|
|
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
|
|
|
|
Cache<DeviceCacheKey, Device> lCache = DeviceManagerUtil.getDeviceCache();
|
|
|
|
|
|
|
|
if (lCache != null) {
|
|
|
|
return lCache.get(getCacheKey(deviceIdentifier, tenantId));
|
|
|
|
return lCache.get(getCacheKey(deviceIdentifier, tenantId));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private DeviceCacheKey getCacheKey(DeviceIdentifier deviceIdentifier, int tenantId) {
|
|
|
|
private DeviceCacheKey getCacheKey(DeviceIdentifier deviceIdentifier, int tenantId) {
|
|
|
|