Interface ConfigurationPropertyCaching
public interface ConfigurationPropertyCaching
Interface that can be used to control configuration property source caches.
- Since:
- 2.3.0
- Author:
- Phillip Webb
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
AutoCloseable
used to control acache override
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the cache and force it to be reloaded on next access.void
disable()
Disable caching.void
enable()
Enable caching with an unlimited time-to-live.static ConfigurationPropertyCaching
get
(Iterable<ConfigurationPropertySource> sources) Get for all specified configuration property sources.static ConfigurationPropertyCaching
get
(Iterable<ConfigurationPropertySource> sources, Object underlyingSource) Get for a specific configuration property source in the specified configuration property sources.static ConfigurationPropertyCaching
get
(Environment environment) Get for all configuration property sources in the environment.static ConfigurationPropertyCaching
get
(Environment environment, Object underlyingSource) Get for a specific configuration property source in the environment.override()
Override caching to temporarily enable it.void
setTimeToLive
(Duration timeToLive) Set amount of time that an item can live in the cache.
-
Method Details
-
enable
void enable()Enable caching with an unlimited time-to-live. -
disable
void disable()Disable caching. -
setTimeToLive
Set amount of time that an item can live in the cache. Calling this method will also enable the cache.- Parameters:
timeToLive
- the time to live value.
-
clear
void clear()Clear the cache and force it to be reloaded on next access. -
override
ConfigurationPropertyCaching.CacheOverride override()Override caching to temporarily enable it. Once caching is no longer needed the returnedConfigurationPropertyCaching.CacheOverride
should be closed to restore previous cache settings.- Returns:
- a
ConfigurationPropertyCaching.CacheOverride
- Since:
- 3.5.0
-
get
Get for all configuration property sources in the environment.- Parameters:
environment
- the spring environment- Returns:
- a caching instance that controls all sources in the environment
-
get
Get for a specific configuration property source in the environment.- Parameters:
environment
- the spring environmentunderlyingSource
- theunderlying source
that must match- Returns:
- a caching instance that controls the matching source
-
get
Get for all specified configuration property sources.- Parameters:
sources
- the configuration property sources- Returns:
- a caching instance that controls the sources
-
get
static ConfigurationPropertyCaching get(Iterable<ConfigurationPropertySource> sources, Object underlyingSource) Get for a specific configuration property source in the specified configuration property sources.- Parameters:
sources
- the configuration property sourcesunderlyingSource
- theunderlying source
that must match- Returns:
- a caching instance that controls the matching source
-