Add a property source that produces a random value that is cached (#719)

* Add a property source that produces a random value that is cached.
This commit is contained in:
Ryan Baxter
2020-03-30 09:25:23 -04:00
committed by GitHub
parent 333779070f
commit 4119a9c138
8 changed files with 289 additions and 3 deletions

View File

@@ -1026,6 +1026,21 @@ public class MyConfiguration {
include::spring-cloud-circuitbreaker.adoc[leveloffset=+1]
== CachedRandomPropertySource
Spring Cloud Context provides a `PropertySource` that caches random values based on a key. Outside of the caching
functionality it works the same as Spring Boot's https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/RandomValuePropertySource.java[`RandomValuePropertySource`].
This random value might be useful in the case where you want a random value that is consistent even after the Spring Application
context restarts. The property value takes the form of `cachedrandom.[yourkey].[type]` where `yourkey` is the key in the cache. The `type` value can
be any type supported by Spring Boot's `RandomValuePropertySource`.
====
[source,properties,indent=0]
----
myrandom=${cachedrandom.appname.value}
----
====
== Configuration Properties
To see the list of all Spring Cloud Commons related configuration properties please check link:appendix.html[the Appendix page].