Skip to content
Snippets Groups Projects
Commit d67e8a3c authored by Riabokon Stanislav(EPAM)[GCP]'s avatar Riabokon Stanislav(EPAM)[GCP]
Browse files

Added cache for PATH endpoint (GONRG-4141)

parent f9eef68e
No related branches found
No related tags found
1 merge request!139Added cache for PATH endpoint (GONRG-4141)
......@@ -71,7 +71,7 @@ public class PartitionServiceImpl implements IPartitionService {
this.partitionPropertyEntityRepository.saveAll(partitionProperties);
PartitionInfo pi = getPartition(partitionId);
if (pi != null) {
if (Objects.nonNull(pi)) {
partitionListCache.clearAll();
}
......@@ -118,6 +118,9 @@ public class PartitionServiceImpl implements IPartitionService {
partitionProperties.add(entity);
}
this.partitionPropertyEntityRepository.saveAll(partitionProperties);
if (Objects.nonNull(partitionServiceCache.get(partitionId))) {
partitionServiceCache.delete(partitionId);
}
return getPartition(partitionId);
}
......@@ -126,13 +129,13 @@ public class PartitionServiceImpl implements IPartitionService {
public PartitionInfo getPartition(String partitionId) {
PartitionInfo pi = partitionServiceCache.get(partitionId);
if (pi == null) {
if (Objects.isNull(pi)) {
pi = getEncryptedPartition(partitionId);
for (Property property : pi.getProperties().values()) {
decryptPartitionPropertyIfNeeded(property);
}
if (pi != null) {
if (Objects.nonNull(pi)) {
partitionServiceCache.put(partitionId, pi);
}
}
......@@ -181,7 +184,7 @@ public class PartitionServiceImpl implements IPartitionService {
}
this.partitionPropertyEntityRepository.deleteByPartitionId(partitionId);
if (partitionServiceCache.get(partitionId) != null) {
if (Objects.nonNull(partitionServiceCache.get(partitionId))) {
partitionServiceCache.delete(partitionId);
}
partitionListCache.clearAll();
......@@ -192,7 +195,7 @@ public class PartitionServiceImpl implements IPartitionService {
public List<String> getAllPartitions() {
List<String> partitions = partitionListCache.get(PARTITION_LIST_KEY);
if (partitions == null) {
if (Objects.isNull(partitions)) {
List<String> allPartitions = this.partitionPropertyEntityRepository.getAllPartitions();
partitions = (allPartitions.isEmpty() ? Collections.emptyList() : allPartitions);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment