Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Do not cache default values across subsequent invocations - #10

Open
oskarwiksten wants to merge 1 commit into
mainfrom
do-not-cache-default-values
Open

Do not cache default values across subsequent invocations#10
oskarwiksten wants to merge 1 commit into
mainfrom
do-not-cache-default-values

Conversation

@oskarwiksten

Copy link
Copy Markdown
Contributor
  • Separate cached DynamicProperty instances not only by their type and property name, but also by which default value the applicaiton requests.
  • Reason for separating is to make different invocations to, for example, getStringProperty(key, default) not always return the default value from the first invocation for subsequent invocations to the property value, if the value is missing from the config source.
  • Previously, code like the following for an empty config source:
String v1 = dynamicConfig.getStringProperty("key", "first").get();
String v2 = dynamicConfig.getStringProperty("key", "second").get();

.. would yield the value "first" for v2. With this commit, v2 will instead get the value "second".

@oskarwiksten
oskarwiksten force-pushed the do-not-cache-default-values branch 2 times, most recently from bdff02b to 1c83e50 Compare October 14, 2021 05:44
* Separate cached `DynamicProperty` instances not only by their type and property name, but also by which default value the applicaiton requests.
* Reason for separating is to make different invocations to, for example, `getStringProperty(key, default)` not always return the default value from the first invocation for subsequent invocations to the property value, if the value is missing from the config source.
* Previously, code like the following for an empty config source:
```
String v1 = dynamicConfig.getStringProperty("key", "first").get();
String v2 = dynamicConfig.getStringProperty("key", "second").get();
```
.. would yield the value `"first"` for `v2`. With this commit, `v2` will instead get the value `"second"`.
@oskarwiksten
oskarwiksten force-pushed the do-not-cache-default-values branch from 1c83e50 to ad29d23 Compare October 19, 2021 14:06

@askoog askoog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea! This is more intuitive than the present solution. Might require some investigation about current usage though. This change might lead to unexpected behavior

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants