-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cache config bug #247
Merged
Merged
Fix cache config bug #247
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original behaviour: A default cache manager with cache key 'DynamicCachedFontsFontCacheKey' was used which stored font files in a folder with the same name. If a value for `cacheStalePeriod` or `maxCacheObjects` is provided which differs from the default value then a new instance of `CacheManager` would be created with the generated `cacheKey`. Problem: Once a garbage collecttion event is run, `_cacheManagers` is destroyed and hence the package forgets about the modified `CacheManager` and attempts to locate the file in the default cache folder (as mentioned above). Solution: There will be no default instance of `CacheManager`, instead an instance will be created using `cacheKey` after any garbage collection events (which includes app restarts). The first time a font is stored will be done using the cache config provided and for subsequent retrievals, `CacheManger` with `cacheKey` will be used and so the package will look for the font file in the right place. See #233 BREAKING CHANGES: This commit does not include any changes to the public API. However, as mentioned above, font files which have already been cached under 'DynamicCachedFontsFontCacheKey' will no longer be used. A migration tool will be provided to delete old font files.
Any font files under 'DynamicCachedFontsFontCacheKey' will be deleted.
sidrao2006
had a problem deploying
to
Test Lab Integration Test
June 10, 2024 18:34 — with
GitHub Actions
Failure
sidrao2006
temporarily deployed
to
Actions Integration Test
June 10, 2024 18:34 — with
GitHub Actions
Inactive
sidrao2006
temporarily deployed
to
Actions Integration Test
June 10, 2024 18:34 — with
GitHub Actions
Inactive
sidrao2006
had a problem deploying
to
Actions Integration Test
June 10, 2024 18:34 — with
GitHub Actions
Failure
sidrao2006
temporarily deployed
to
Actions Integration Test
June 10, 2024 18:34 — with
GitHub Actions
Inactive
sidrao2006
temporarily deployed
to
Actions Integration Test
June 10, 2024 18:34 — with
GitHub Actions
Inactive
**For package users with custom values for `cacheStalePeriod`, `maxCacheObjects`, these values must be passed to any method provided by this package. Otherwise the provided config values will be ignored.** **For package users who didn't modify these properties, no changes are required. The default values will be used.** Changes: - Require `cacheStalePeriod`, `maxCacheObjects` to be passed to any method that calls `getCacheManager`. As a result, if the above mentioned properties are modified by the user of the package at any point, the modified values should be passed to any method provided by this package - Require `cacheStalePeriod`, `maxCacheObjects` to be passed to `getCacheManager` - Remove `handleCacheManager` Problem: `CacheManager` requires a singleton approach. Since each `cacheKey` requires a unique instance of `CacheManager`, calling any method provided by the package before calling `cacheFont`/`cacheFontStream` would result in `cacheStalePeriod`, `maxCacheObjects` to be ignored when downloading and adding the font to cache. Solution: By accepting `cacheStalePeriod`, `maxCacheObjects` as args in all methods, the instance of `CacheManager` created will use the provided config.
sidrao2006
temporarily deployed
to
Actions Integration Test
June 11, 2024 09:28 — with
GitHub Actions
Inactive
sidrao2006
had a problem deploying
to
Test Lab Integration Test
June 11, 2024 09:28 — with
GitHub Actions
Failure
sidrao2006
temporarily deployed
to
Actions Integration Test
June 11, 2024 09:28 — with
GitHub Actions
Inactive
sidrao2006
had a problem deploying
to
Actions Integration Test
June 11, 2024 09:28 — with
GitHub Actions
Failure
sidrao2006
had a problem deploying
to
Actions Integration Test
June 11, 2024 09:28 — with
GitHub Actions
Failure
sidrao2006
temporarily deployed
to
Actions Integration Test
June 11, 2024 09:28 — with
GitHub Actions
Inactive
sidrao2006
temporarily deployed
to
Test Lab Integration Test
June 11, 2024 09:46 — with
GitHub Actions
Inactive
sidrao2006
temporarily deployed
to
Actions Integration Test
June 11, 2024 09:46 — with
GitHub Actions
Inactive
sidrao2006
temporarily deployed
to
Actions Integration Test
June 11, 2024 09:46 — with
GitHub Actions
Inactive
sidrao2006
temporarily deployed
to
Actions Integration Test
June 11, 2024 09:46 — with
GitHub Actions
Inactive
sidrao2006
had a problem deploying
to
Actions Integration Test
June 11, 2024 09:46 — with
GitHub Actions
Failure
sidrao2006
temporarily deployed
to
Actions Integration Test
June 11, 2024 09:46 — with
GitHub Actions
Inactive
sidrao2006
added a commit
that referenced
this pull request
Nov 28, 2024
This reverts commit 3aff4d1.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Breaking Changes and Migration Guide
If you have been using the package without modifying
cacheStalePeriod
ormaxCacheObjects
, no changes are required.However, any previously cached font files will be ignored and should be deleted by running the migration tool.
If you have modified
cacheStalePeriod
ormaxCacheObjects
, you'll have to pass the same values to any method that downloads, caches or loads fonts, otherwise the provided configuration will be ignored.Any previously cached font files will continue to remain in their respective cache folders and will be used by the package.
Running the migration tool will have no effect on these font files.
A migration tool has been provided ->
DynamicCachedFonts.runMigrationTool()
Original behaviour: A default cache manager with cache key 'DynamicCachedFontsFontCacheKey' was used which stored font files in a folder with the same name.
If a value for
cacheStalePeriod
ormaxCacheObjects
is provided which differs from the default value then a new instance ofCacheManager
would be created with the generatedcacheKey
.Problems:
Once a garbage collection event is run,
_cacheManagers
is destroyed and hence the package forgets about the modifiedCacheManager
and attempts to locate the file in the default cache folder (as mentioned above).CacheManager
requires a singleton approach. Since eachcacheKey
requires a unique instance ofCacheManager
, calling any method provided by the package before callingcacheFont
/cacheFontStream
would result incacheStalePeriod
,maxCacheObjects
to be ignored when downloading and adding the font to cache.Solutions:
There will be no default instance of
CacheManager
, instead an instance will be created usingcacheKey
after any garbage collection events (which includes app restarts).Any method that downloads, caches or loads font will now accept
cacheStalePeriod
,maxCacheObjects
. This ensures that an instance ofCacheManager
will be created only once with the provided configChanges:
cacheStalePeriod
,maxCacheObjects
to be passed to anymethod that calls
getCacheManager
. As a result, if the above mentionedproperties are modified by the user of the package at any point, the
modified values should be passed to any method provided by this package
cacheStalePeriod
,maxCacheObjects
to be passed togetCacheManager
handleCacheManager
See #233