Cache of requests' responses with TTL support and configurable cacheable commands.
More...
#include <ResponseExpirationCache.hpp>
|
| | 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) const |
| | Get a response from the cache.
|
| void | put (std::string const &cmd, 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.
◆ ResponseExpirationCache()
| util::ResponseExpirationCache::ResponseExpirationCache |
( |
std::chrono::steady_clock::duration | cacheTimeout, |
|
|
std::unordered_set< std::string > const & | cmds ) |
|
inline |
Construct a new Cache object.
- Parameters
-
| cacheTimeout | The time for cache entries to expire |
| cmds | The commands that should be cached |
◆ get()
| std::optional< boost::json::object > util::ResponseExpirationCache::get |
( |
std::string const & | cmd | ) |
const |
|
nodiscard |
Get a response from the cache.
- Parameters
-
| cmd | The command to get the response for |
- Returns
- The response if it exists or std::nullopt otherwise
◆ put()
| void util::ResponseExpirationCache::put |
( |
std::string const & | cmd, |
|
|
boost::json::object const & | response ) |
Put a response into the cache if the request should be cached.
- Parameters
-
| cmd | The command to store the response for |
| response | The response to store |
The documentation for this class was generated from the following files: