diff --git a/docs/src/main/asciidoc/spring-cloud-commons.adoc b/docs/src/main/asciidoc/spring-cloud-commons.adoc index bc87967c..43299c83 100644 --- a/docs/src/main/asciidoc/spring-cloud-commons.adoc +++ b/docs/src/main/asciidoc/spring-cloud-commons.adoc @@ -809,7 +809,7 @@ implementation. To make use of it, you need to have `com.github.ben-manes.caffeine:caffeine` in the classpath. The default setup includes `expireAfterWrite` set to 30 seconds and records set to soft references. -You can set your own `TTL` value (the time after write after which entries should be expired), expressed as `Duration`, by passing a `String` compliant with the https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Duration.html#parse(java.lang.CharSequence)[`Duration` API] +You can set your own `TTL` value (the time after write after which entries should be expired), expressed as `Duration`, by passing a `String` compliant with the https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config-conversion-duration[Spring Boot `String` to `Duration` converter syntax]. as the value of `spring.cloud.loadbalancer.cache.ttl` property. You can also override the default Caffeine Cache setup for the LoadBalancer by passing your own https://static.javadoc.io/com.github.ben-manes.caffeine/caffeine/2.2.2/com/github/benmanes/caffeine/cache/CaffeineSpec.html[Caffeine Specification] diff --git a/spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/cache/CaffeineBasedLoadBalancerCacheManager.java b/spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/cache/CaffeineBasedLoadBalancerCacheManager.java index f9a60631..a7c40601 100644 --- a/spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/cache/CaffeineBasedLoadBalancerCacheManager.java +++ b/spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/cache/CaffeineBasedLoadBalancerCacheManager.java @@ -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 diff --git a/spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/cache/LoadBalancerCacheProperties.java b/spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/cache/LoadBalancerCacheProperties.java index 52b4d1d0..f396b831 100644 --- a/spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/cache/LoadBalancerCacheProperties.java +++ b/spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/cache/LoadBalancerCacheProperties.java @@ -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 + * StringToDurationConverter. + * @see StringToDurationConverter.java */ 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 {