-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
KTOR-6001 Cache returns null when vary header has more fields in the cached response #3655
Conversation
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.
Sorry, accidentally missed this pr :) I have some comments
@@ -42,7 +42,9 @@ internal class UnlimitedStorage : CacheStorage { | |||
|
|||
override suspend fun find(url: Url, varyKeys: Map<String, String>): CachedResponseData? { | |||
val data = store.computeIfAbsent(url) { ConcurrentSet() } | |||
return data.find { it.varyKeys == varyKeys } | |||
return data.find { |
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.
There is one more find
function on line 23, should we also change it like 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.
This is the legacy storage, but I changed it as well. Thanks!
@@ -42,7 +42,9 @@ internal class UnlimitedStorage : CacheStorage { | |||
|
|||
override suspend fun find(url: Url, varyKeys: Map<String, String>): CachedResponseData? { | |||
val data = store.computeIfAbsent(url) { ConcurrentSet() } | |||
return data.find { it.varyKeys == varyKeys } | |||
return data.find { | |||
varyKeys.all { (key, value) -> it.varyKeys[key] == value } |
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.
Shouldn't we also check the equal size of maps?
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.
No, it's ok if cached version has more vary properties, than the 304 response
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.
lgtm
https://youtrack.jetbrains.com/issue/KTOR-6001