Skip to content

Set initial cache expiry time after all settings have been loaded - #204

Merged
Avani Gupta (avanigupta) merged 7 commits into
mainfrom
avanigupta/cacheexpirationbug
Oct 12, 2020
Merged

Avani Gupta (avanigupta) merged 7 commits into
mainfrom
avanigupta/cacheexpirationbug

Conversation

@avanigupta

Copy link
Copy Markdown
Member

Fix #172

Comment thread tests/Tests.AzureAppConfiguration/RefreshTests.cs Outdated
Comment thread tests/Tests.AzureAppConfiguration/RefreshTests.cs Outdated
Comment thread tests/Tests.AzureAppConfiguration/RefreshTests.cs
Comment thread tests/Tests.AzureAppConfiguration/RefreshTests.cs Outdated
Comment thread tests/Tests.AzureAppConfiguration/FeatureManagementTests.cs Outdated
Comment thread tests/Tests.AzureAppConfiguration/FeatureManagementTests.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. One question. What's the purpose of the last commit to initialize cachedData to string.Empty?

@avanigupta

Avani Gupta (avanigupta) commented Oct 10, 2020

Copy link
Copy Markdown
Member Author

Looks good. One question. What's the purpose of the last commit to initialize cachedData to string.Empty?

As Abhilash suggested in this comment: #204 (comment)

I moved the cache exporting logic back to the end of LoadAll. So before exporting, we just need to check if the data was loaded from server or from offline cache. If it was loaded from offline cache, we don't need to export the same data again. That's why I initialized cachedData at the beginning of LoadAll so that it can be accessed both inside and outside the catch block.

@jimmyca15

Jimmy Campbell (jimmyca15) commented Oct 10, 2020

Copy link
Copy Markdown
Member

Looks good. One question. What's the purpose of the last commit to initialize cachedData to string.Empty?

As Abhilash suggested in this comment: #204 (comment)

I moved the cache exporting logic back to the end of LoadAll. So before exporting, we just need to check if the data was loaded from server or from offline cache. If it was loaded from offline cache, we don't need to export the same data again. That's why I initialized cachedData at the beginning of LoadAll so that it can be accessed both inside and outside the catch block.

I get that. Not sure why it is initialized to string.Empty instead of null. The default initialization of a string is null so the fact that it's explicitly initialized to an empty string makes it look like it's for some purpose.

@avanigupta
Avani Gupta (avanigupta) force-pushed the avanigupta/cacheexpirationbug branch from 40a8972 to 924352c Compare October 10, 2020 21:20
@avanigupta

Copy link
Copy Markdown
Member Author

Looks good. One question. What's the purpose of the last commit to initialize cachedData to string.Empty?

As Abhilash suggested in this comment: #204 (comment)
I moved the cache exporting logic back to the end of LoadAll. So before exporting, we just need to check if the data was loaded from server or from offline cache. If it was loaded from offline cache, we don't need to export the same data again. That's why I initialized cachedData at the beginning of LoadAll so that it can be accessed both inside and outside the catch block.

I get that. Not sure why it is initialized to string.Empty instead of null. The default initialization of a string is null so the fact that it's explicitly initialized to an empty string makes it look like it's for some purpose.

Good point, thanks! Reverted the last commit. We also don't need to check if OfflineCache.Import returned empty string because it always returns null if the encrypted data in offline cache file is invalid (or throws an exception if the file cannot be accessed). So a simple null check will suffice.

@avanigupta
Avani Gupta (avanigupta) deleted the avanigupta/cacheexpirationbug branch October 12, 2020 18:10
Avani Gupta (avanigupta) added a commit that referenced this pull request Oct 22, 2020
* Set initial cache expiry after all settings are loaded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache expiration is ignored on first call to RefreshAsync

3 participants