Skip to content

Commit

Permalink
PAGOPA-2442 update client calling cache
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoRuzzier committed Nov 29, 2024
1 parent 096ded4 commit 8aaca61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;

import java.util.List;
import java.util.Map;

@Service
Expand All @@ -25,21 +23,18 @@ public class ConfigCacheService {
@Getter
private it.gov.pagopa.gen.wispconverter.client.cache.model.ConfigDataV1Dto configData;

@Value("${client.cache.keys}")
private List<String> cacheKeys;

public void refreshCache() {
log.debug("loadCache from cache api");

try {
it.gov.pagopa.gen.wispconverter.client.cache.api.CacheApi apiInstance = new it.gov.pagopa.gen.wispconverter.client.cache.api.CacheApi(configCacheClient);
if (configData == null) {
configData = apiInstance.get(cacheKeys);
configData = apiInstance.cache(false);
log.debug("loadCache from cache api...done");
} else {
CacheVersionDto id = apiInstance.id();
if (!configData.getVersion().equals(id.getVersion())) {
configData = apiInstance.get(cacheKeys);
CacheVersionDto id = apiInstance.idV1();
if (!configData.getVersion().equals(id)) {
configData = apiInstance.cache(false);
log.debug("loadCache from cache api...done");
}
}
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ client.cache.read-timeout=${CLIENT_CACHE_READ_TIMEOUT:5000}
client.cache.connect-timeout=${CLIENT_CACHE_READ_TIMEOUT:5000}
client.cache.base-path=${CLIENT_CACHE_HOST:none}
client.cache.api-key=${CLIENT_CACHE_SUBKEY:none}
client.cache.keys=


# RE tracing levels
Expand Down

0 comments on commit 8aaca61

Please sign in to comment.