Switch to Spring Boot String to Duration conversion.

This commit is contained in:
Olga Maciaszek-Sharma
2019-11-22 16:49:28 +01:00
parent bf6b31ee8a
commit 1ddeca4a8e
3 changed files with 11 additions and 10 deletions

View File

@@ -24,8 +24,8 @@ import org.springframework.util.StringUtils;
import static org.springframework.cloud.loadbalancer.core.CachingServiceInstanceListSupplier.SERVICE_INSTANCE_CACHE_NAME;
/**
* A Spring Cloud LoadBalancer specific implementation of {@link CaffeineCacheManager} that
* implements the {@link LoadBalancerCacheManager} marker interface.
* A Spring Cloud LoadBalancer specific implementation of {@link CaffeineCacheManager}
* that implements the {@link LoadBalancerCacheManager} marker interface.
*
* @author Olga Maciaszek-Sharma
* @since 2.2.0

View File

@@ -34,8 +34,10 @@ public class LoadBalancerCacheProperties {
/**
* Time To Live - time counted from writing of the record, after which cache entries
* are expired, expressed as a {@link Duration}. The property {@link String} has to be
* in keeping with the appropriate syntax as specified in
* {@link Duration#parse(CharSequence)}.
* in keeping with the appropriate syntax as specified in Spring Boot
* <code>StringToDurationConverter</code>.
* @see <a href=
* "https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/StringToDurationConverter.java">StringToDurationConverter.java</a>
*/
private Duration ttl = Duration.ofSeconds(30);
@@ -51,14 +53,13 @@ public class LoadBalancerCacheProperties {
return ttl;
}
public void setTtl(String ttl) {
this.ttl = Duration.parse(ttl);
public void setTtl(Duration ttl) {
this.ttl = ttl;
}
/**
* Caffeine-specific LoadBalancer cache properties.
* NOTE: Passing your own Caffeine specification will override any other LoadBalancerCache settings,
* including TTL.
* Caffeine-specific LoadBalancer cache properties. NOTE: Passing your own Caffeine
* specification will override any other LoadBalancerCache settings, including TTL.
*/
public static class Caffeine {