cesium-native  0.41.0
CacheItem.h
1 #pragma once
2 
3 #include "HttpHeaders.h"
4 #include "Library.h"
5 
6 #include <gsl/span>
7 
8 #include <cstddef>
9 #include <cstdint>
10 #include <ctime>
11 #include <map>
12 #include <vector>
13 
14 namespace CesiumAsync {
15 
19 class CESIUMASYNC_API CacheResponse {
20 public:
28  uint16_t cacheStatusCode,
29  HttpHeaders&& cacheHeaders,
30  std::vector<std::byte>&& cacheData)
31  : statusCode(cacheStatusCode),
32  headers(std::move(cacheHeaders)),
33  data(std::move(cacheData)) {}
34 
38  uint16_t statusCode;
39 
44 
48  std::vector<std::byte> data;
49 };
50 
54 class CESIUMASYNC_API CacheRequest {
55 public:
63  HttpHeaders&& cacheHeaders,
64  std::string&& cacheMethod,
65  std::string&& cacheUrl)
66  : headers(std::move(cacheHeaders)),
67  method(std::move(cacheMethod)),
68  url(std::move(cacheUrl)) {}
69 
74 
78  std::string method;
79 
83  std::string url;
84 };
85 
89 class CESIUMASYNC_API CacheItem {
90 public:
98  std::time_t cacheExpiryTime,
99  CacheRequest&& request,
100  CacheResponse&& response)
101  : expiryTime(cacheExpiryTime),
102  cacheRequest(std::move(request)),
103  cacheResponse(std::move(response)) {}
104 
108  std::time_t expiryTime;
109 
114 
119 };
120 } // namespace CesiumAsync
Cache item retrieved from the cache database.
Definition: CacheItem.h:89
CacheItem(std::time_t cacheExpiryTime, CacheRequest &&request, CacheResponse &&response)
Constructor.
Definition: CacheItem.h:97
CacheRequest cacheRequest
The cache request owned by this cache item.
Definition: CacheItem.h:113
std::time_t expiryTime
The time point that this cache item is expired.
Definition: CacheItem.h:108
CacheResponse cacheResponse
The cache response owned by this cache item.
Definition: CacheItem.h:118
Cache request retrieved from the cache database.
Definition: CacheItem.h:54
std::string method
The method of the request.
Definition: CacheItem.h:78
std::string url
The url of the request.
Definition: CacheItem.h:83
HttpHeaders headers
The headers of the request.
Definition: CacheItem.h:73
CacheRequest(HttpHeaders &&cacheHeaders, std::string &&cacheMethod, std::string &&cacheUrl)
Constructor.
Definition: CacheItem.h:62
Cache response retrieved from the cache database.
Definition: CacheItem.h:19
HttpHeaders headers
The headers of the response.
Definition: CacheItem.h:43
CacheResponse(uint16_t cacheStatusCode, HttpHeaders &&cacheHeaders, std::vector< std::byte > &&cacheData)
Constructor.
Definition: CacheItem.h:27
std::vector< std::byte > data
The body data of the response.
Definition: CacheItem.h:48
uint16_t statusCode
The status code of the response.
Definition: CacheItem.h:38
Classes that support asynchronous operations.
std::map< std::string, std::string, CaseInsensitiveCompare > HttpHeaders
Http Headers that maps case-insensitive header key with header value.
Definition: HttpHeaders.h:23