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.
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(common): fix cache ttl not beeing respected #11131
fix(common): fix cache ttl not beeing respected #11131
Changes from 1 commit
e151c47
63814af
e7b38a0
7ef71f3
ee11bea
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the name of this constant
cacheManagerIsv5OrGreater
I would change, to make it a little more readable, otherwise it looks good. 👍Just one question the interceptor continues to work with both cache-manager v4 and v5, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It falls back to using the old signature if the version is below v5. So there should be no change to the code for that case.
cacheManagerIsv5OrGreater
is beeing used in thepackages/common/cache/cache.providers.ts
as well to use milliseconds instead of seconds for the default TTL of five seconds. So I assumed the check is correct.Any suggestions about naming this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, for the name
cacheManagerIsv5OrGreater
if it's already used internally already in common then it's better to use this, sure it's a bit strange name 😄 . Anyway the variable name from what I understand should mean:" Cache manager is version 5 or higher "
.At the moment one name could be
"cacheManagerVersions"
, it is an idea 😄, if you change it here you should also change it topackages/common/cache/cache.providers.ts
.Howerer if I have other names I will write to you here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
" Cache manager is version 5 or higher "
This is exactly what the variable is ment to be.It's a boolean that is true if the package beeing loaded is v5 or greater
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree with that, no problem, but I think the name could be improved, maybe even something like "
cacheManagerCheckVersions
", however i repeat no problem 👍There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to do this check lazily otherwise we end up forcing everyone to have
cache-manager
installedWhat about having a private method at
CacheInterceptor
just for this role? it would return a booleanOr, better yet(?), we could have a internal utility function at
cache.providers.ts
that will do that check. Then we can use the same function oncreateCacheManager
as well to avoid duplicating logicThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like the best solution.
The
loadPackage
function is logging when it could not load the dependency in its catch.Do we want to modify that function with a parameter to disable that log, or do we want to refactor that function so it uses a new function without the logging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should keep the current behavior, which is just like how
createCacheManager
works.