cesium-native 0.43.0
Loading...
Searching...
No Matches
SqliteCache.h
1#pragma once
2
3#include "ICacheDatabase.h"
4
5#include <spdlog/fwd.h>
6
7#include <cstddef>
8#include <memory>
9#include <optional>
10#include <string>
11
12namespace CesiumAsync {
13
17class CESIUMASYNC_API SqliteCache : public ICacheDatabase {
18public:
32 const std::shared_ptr<spdlog::logger>& pLogger,
33 const std::string& databaseName,
34 uint64_t maxItems = 4096);
36
38 virtual std::optional<CacheItem>
39 getEntry(const std::string& key) const override;
40
42 virtual bool storeEntry(
43 const std::string& key,
44 std::time_t expiryTime,
45 const std::string& url,
46 const std::string& requestMethod,
47 const HttpHeaders& requestHeaders,
48 uint16_t statusCode,
49 const HttpHeaders& responseHeaders,
50 const std::span<const std::byte>& responseData) override;
51
53 virtual bool prune() override;
54
56 virtual bool clearAll() override;
57
58private:
59 struct Impl;
60 std::unique_ptr<Impl> _pImpl;
61 void createConnection() const;
62 void destroyDatabase();
63};
64} // namespace CesiumAsync
Provides database storage interface to cache completed request.
Cache storage using SQLITE to store completed response.
Definition SqliteCache.h:17
virtual std::optional< CacheItem > getEntry(const std::string &key) const override
Gets a cache entry from the database.
virtual bool prune() override
Remove cache entries from the database to satisfy the database invariant condition (....
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 std::span< const std::byte > &responseData) override
Store a cache entry in the database.
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.
virtual bool clearAll() override
Removes all cache entries from the database.
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:25