|
|
|
@ -30,6 +30,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.thingsboard.server.cache.TbCacheValueWrapper; |
|
|
|
import org.thingsboard.server.cache.VersionedTbCache; |
|
|
|
import org.thingsboard.server.common.data.AttributeScope; |
|
|
|
import org.thingsboard.server.common.data.EntityType; |
|
|
|
import org.thingsboard.server.common.data.ObjectType; |
|
|
|
import org.thingsboard.server.common.data.StringUtils; |
|
|
|
import org.thingsboard.server.common.data.edqs.AttributeKv; |
|
|
|
@ -239,7 +240,8 @@ public class CachedAttributesService implements AttributesService { |
|
|
|
ListenableFuture<Long> future = Futures.transform(attributesDao.save(tenantId, entityId, scope, attribute), version -> { |
|
|
|
BaseAttributeKvEntry attributeKvEntry = new BaseAttributeKvEntry(((BaseAttributeKvEntry) attribute).getKv(), attribute.getLastUpdateTs(), version); |
|
|
|
put(entityId, scope, attributeKvEntry); |
|
|
|
edqsService.onUpdate(tenantId, ObjectType.ATTRIBUTE_KV, new AttributeKv(entityId, scope, attributeKvEntry, version)); |
|
|
|
TenantId edqsTenantId = entityId.getEntityType() == EntityType.TENANT ? (TenantId) entityId : tenantId; |
|
|
|
edqsService.onUpdate(edqsTenantId, ObjectType.ATTRIBUTE_KV, new AttributeKv(entityId, scope, attributeKvEntry, version)); |
|
|
|
return version; |
|
|
|
}, cacheExecutor); |
|
|
|
futures.add(future); |
|
|
|
@ -263,7 +265,8 @@ public class CachedAttributesService implements AttributesService { |
|
|
|
Long version = keyVersionPair.getSecond(); |
|
|
|
cache.evict(new AttributeCacheKey(scope, entityId, key), version); |
|
|
|
if (version != null) { |
|
|
|
edqsService.onDelete(tenantId, ObjectType.ATTRIBUTE_KV, new AttributeKv(entityId, scope, key, version)); |
|
|
|
TenantId edqsTenantId = entityId.getEntityType() == EntityType.TENANT ? (TenantId) entityId : tenantId; |
|
|
|
edqsService.onDelete(edqsTenantId, ObjectType.ATTRIBUTE_KV, new AttributeKv(entityId, scope, key, version)); |
|
|
|
} |
|
|
|
return key; |
|
|
|
}, cacheExecutor)).toList()); |
|
|
|
|