diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheProperties.java index 22c4731c14..49af8f0259 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.cache; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.core.io.Resource; @@ -139,7 +140,8 @@ public class CacheProperties { public static class Couchbase { /** - * Entry expiration in milliseconds. By default the entries never expire. + * Entry expiration in milliseconds. By default the entries never expire. Note + * that this value is ultimately converted to seconds. */ private int expiration; @@ -147,6 +149,14 @@ public class CacheProperties { return this.expiration; } + /** + * Return the expiration in seconds. + * @return the expiration in seconds + */ + public int getExpirationSeconds() { + return (int) TimeUnit.MILLISECONDS.toSeconds(this.expiration); + } + public void setExpiration(int expiration) { this.expiration = expiration; } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CouchbaseCacheConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CouchbaseCacheConfiguration.java index a66dda2b1b..3813a40a61 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CouchbaseCacheConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CouchbaseCacheConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,8 +60,8 @@ public class CouchbaseCacheConfiguration { public CouchbaseCacheManager cacheManager() { List cacheNames = this.cacheProperties.getCacheNames(); CouchbaseCacheManager cacheManager = new CouchbaseCacheManager( - CacheBuilder.newInstance(this.bucket).withExpirationInMillis( - this.cacheProperties.getCouchbase().getExpiration()), + CacheBuilder.newInstance(this.bucket).withExpiration( + this.cacheProperties.getCouchbase().getExpirationSeconds()), cacheNames.toArray(new String[cacheNames.size()])); return this.customizers.customize(cacheManager); } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java index fbe7b07deb..6c404eeb34 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -247,7 +247,7 @@ public class CacheAutoConfigurationTests { assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar"); Cache cache = cacheManager.getCache("foo"); assertThat(cache).isInstanceOf(CouchbaseCache.class); - assertThat(((CouchbaseCache) cache).getTtl()).isEqualTo(2000); + assertThat(((CouchbaseCache) cache).getTtl()).isEqualTo(2); assertThat(((CouchbaseCache) cache).getNativeCache()) .isEqualTo(this.context.getBean("bucket")); } diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 22e9b95986..b9a30d6061 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -62,7 +62,7 @@ 1.6 2.4.2 2.3.6 - 2.0.0 + 2.1.0 10.13.1.1 1.6.1 3.1.2 diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 6e3928794b..4204023edf 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -4082,7 +4082,7 @@ cache: public CacheManagerCustomizer cacheManagerCustomizer() { return c -> { c.prepareCache("biz", CacheBuilder.newInstance(anotherBucket()) - .withExpirationInMillis(2000)); + .withExpiration(2)); }; }