mirror of
https://github.com/XRPLF/clio.git
synced 2026-07-30 02:20:28 +00:00
fix: Don't cache requests with params (#3113)
`ResponseExpirationCache` is using only `method` (or `command`) as a key, but responses might be different with different params. This may lead to a client getting incorrect response because of caching. This PR fixes it by caching only requests without any additional params.
This commit is contained in:
@@ -277,7 +277,7 @@ LoadBalancer::forwardToRippled(
|
||||
auto const cmd = boost::json::value_to<std::string>(request.at("command"));
|
||||
if (shouldUseCache(isAdmin)) {
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
if (auto cachedResponse = forwardingCache_->get(cmd); cachedResponse) {
|
||||
if (auto cachedResponse = forwardingCache_->get(cmd, request); cachedResponse) {
|
||||
forwardingCounters_.cacheHit.get() += 1;
|
||||
return *std::move(cachedResponse);
|
||||
}
|
||||
@@ -311,8 +311,10 @@ LoadBalancer::forwardToRippled(
|
||||
}
|
||||
|
||||
if (response) {
|
||||
if (shouldUseCache(isAdmin) and not response->contains("error"))
|
||||
forwardingCache_->put(cmd, *response); // NOLINT(bugprone-unchecked-optional-access)
|
||||
if (shouldUseCache(isAdmin) and not response->contains("error")) {
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
forwardingCache_->put(cmd, request, *response);
|
||||
}
|
||||
return *std::move(response);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user