cesium-native
0.41.0
|
Cache storage using SQLITE to store completed response. More...
#include <CesiumAsync/SqliteCache.h>
Public Member Functions | |
SqliteCache (const std::shared_ptr< spdlog::logger > &pLogger, const std::string &databaseName, uint64_t maxItems=4096) | |
Constructs a new instance with a given databaseName pointing to a database. More... | |
virtual std::optional< CacheItem > | getEntry (const std::string &key) const override |
Gets a cache entry from the database. More... | |
virtual bool | storeEntry (const std::string &key, std::time_t expiryTime, const std::string &url, const std::string &requestMethod, const HttpHeaders &requestHeaders, uint16_t statusCode, const HttpHeaders &responseHeaders, const gsl::span< const std::byte > &responseData) override |
Store a cache entry in the database. More... | |
virtual bool | prune () override |
Remove cache entries from the database to satisfy the database invariant condition (.e.g exired response or LRU). More... | |
virtual bool | clearAll () override |
Removes all cache entries from the database. More... | |
Cache storage using SQLITE to store completed response.
Definition at line 17 of file SqliteCache.h.
CesiumAsync::SqliteCache::SqliteCache | ( | const std::shared_ptr< spdlog::logger > & | pLogger, |
const std::string & | databaseName, | ||
uint64_t | maxItems = 4096 |
||
) |
Constructs a new instance with a given databaseName
pointing to a database.
The instance will connect to the existing database or create a new one if it doesn't exist
pLogger | The logger that receives error messages. |
databaseName | the database path. |
maxItems | the maximum number of items should be kept in the database after prunning. |
|
overridevirtual |
Removes all cache entries from the database.
true
if the database was successfully cleared, or false
if it could not be pruned due to an errror. Implements CesiumAsync::ICacheDatabase.
|
overridevirtual |
Gets a cache entry from the database.
If an error prevents checking the database for the key, this function, depending on the implementation, may log the error. However, it should return std::nullopt
. It should not throw an exception.
key | The unique key associated with the cache entry. |
std::nullopt
if the key does not exist in the cache or an error occurred. Implements CesiumAsync::ICacheDatabase.
|
overridevirtual |
Remove cache entries from the database to satisfy the database invariant condition (.e.g exired response or LRU).
true
if the database was successfully pruned, or false
if it could not be pruned due to an errror. Implements CesiumAsync::ICacheDatabase.
|
overridevirtual |
Store a cache entry in the database.
key | the unique key associated with the response |
expiryTime | the time point that this response should be expired. An expired response will be removed when prunning the database. |
url | The URL being cached. |
requestMethod | The HTTP method being cached. |
requestHeaders | The HTTP request headers being cached. |
statusCode | The HTTP response status code being cached. |
responseHeaders | The HTTP response headers being cached. |
responseData | The HTTP response being cached. |
true
if the entry was successfully stored, or false
if it could not be stored due to an error. Implements CesiumAsync::ICacheDatabase.