|
Clio
develop
The XRP Ledger API server.
|
Cache of requests' responses with TTL support and configurable cacheable commands. More...
#include <ResponseExpirationCache.hpp>
Public Member Functions | |
| ResponseExpirationCache (std::chrono::steady_clock::duration cacheTimeout, std::unordered_set< std::string > const &cmds) | |
| Construct a new Cache object. | |
| std::optional< boost::json::object > | get (std::string const &cmd, boost::json::object const &request) const |
| Get a response from the cache. | |
| void | put (std::string const &cmd, boost::json::object const &request, boost::json::object const &response) |
| Put a response into the cache if the request should be cached. | |
| void | invalidate () |
| Invalidate all entries in the cache. | |
Cache of requests' responses with TTL support and configurable cacheable commands.
|
inline |
Construct a new Cache object.
| cacheTimeout | The time for cache entries to expire |
| cmds | The commands that should be cached |
|
nodiscard |
Get a response from the cache.
Only bare requests (those carrying no response-customizing params beyond "command", "method", and "id") are served from the cache. Non-bare requests always return std::nullopt.
| cmd | The command to get the response for |
| request | The full request object; used to determine whether the request is bare |
| void util::ResponseExpirationCache::put | ( | std::string const & | cmd, |
| boost::json::object const & | request, | ||
| boost::json::object const & | response ) |
Put a response into the cache if the request should be cached.
Only bare requests (those carrying no response-customizing params beyond "command", "method", and "id") are stored in the cache. Non-bare requests are silently ignored.
| cmd | The command to store the response for |
| request | The full request object; used to determine whether the request is bare |
| response | The response to store |