cesium-native
0.41.0
|
A decorator for an IAssetAccessor that caches requests and responses in an ICacheDatabase. More...
#include <CesiumAsync/CachingAssetAccessor.h>
Public Member Functions | |
CachingAssetAccessor (const std::shared_ptr< spdlog::logger > &pLogger, const std::shared_ptr< IAssetAccessor > &pAssetAccessor, const std::shared_ptr< ICacheDatabase > &pCacheDatabase, int32_t requestsPerCachePrune=10000) | |
Constructs a new instance. More... | |
virtual Future< std::shared_ptr< IAssetRequest > > | get (const AsyncSystem &asyncSystem, const std::string &url, const std::vector< THeader > &headers) override |
Starts a new request for the asset with the given URL. The request proceeds asynchronously without blocking the calling thread. More... | |
virtual Future< std::shared_ptr< IAssetRequest > > | request (const AsyncSystem &asyncSystem, const std::string &verb, const std::string &url, const std::vector< THeader > &headers, const gsl::span< const std::byte > &contentPayload) override |
Starts a new request to the given URL, using the provided HTTP verb and the provided content payload. More... | |
virtual void | tick () noexcept override |
Ticks the asset accessor system while the main thread is blocked. More... | |
Additional Inherited Members | |
Public Types inherited from CesiumAsync::IAssetAccessor | |
typedef std::pair< std::string, std::string > | THeader |
An HTTP header represented as a key/value pair. | |
A decorator for an IAssetAccessor that caches requests and responses in an ICacheDatabase.
This can be used to improve asset loading performance by caching assets across runs.
Definition at line 25 of file CachingAssetAccessor.h.
CesiumAsync::CachingAssetAccessor::CachingAssetAccessor | ( | const std::shared_ptr< spdlog::logger > & | pLogger, |
const std::shared_ptr< IAssetAccessor > & | pAssetAccessor, | ||
const std::shared_ptr< ICacheDatabase > & | pCacheDatabase, | ||
int32_t | requestsPerCachePrune = 10000 |
||
) |
Constructs a new instance.
pLogger | The logger that receives messages about the status of this instance. |
pAssetAccessor | The underlying IAssetAccessor used to retrieve assets that are not in the cache. |
pCacheDatabase | The database in which to cache requests and responses. |
requestsPerCachePrune | The number of requests to handle before each ICacheDatabase::prune of old cached results from the database. |
|
overridevirtual |
Starts a new request for the asset with the given URL. The request proceeds asynchronously without blocking the calling thread.
asyncSystem | The async system used to do work in threads. |
url | The URL of the asset. |
headers | The headers to include in the request. |
Implements CesiumAsync::IAssetAccessor.
|
overridevirtual |
Starts a new request to the given URL, using the provided HTTP verb and the provided content payload.
The request proceeds asynchronously without blocking the calling thread.
asyncSystem | The async system used to do work in threads. |
verb | The HTTP verb to use, such as "POST" or "PATCH". |
url | The URL of the asset. |
headers | The headers to include in the request. |
contentPayload | The payload data to include in the request. |
Implements CesiumAsync::IAssetAccessor.
|
overridevirtualnoexcept |
Ticks the asset accessor system while the main thread is blocked.
If the asset accessor is not dependent on the main thread to dispatch requests, this method does not need to do anything.
Implements CesiumAsync::IAssetAccessor.