| 438 | } |
| 439 | |
| 440 | bool SqliteCache::storeEntry( |
| 441 | const std::string& key, |
| 442 | std::time_t expiryTime, |
| 443 | const std::string& url, |
| 444 | const std::string& requestMethod, |
| 445 | const HttpHeaders& requestHeaders, |
| 446 | uint16_t statusCode, |
| 447 | const HttpHeaders& responseHeaders, |
| 448 | const std::span<const std::byte>& responseData) { |
| 449 | CESIUM_TRACE("SqliteCache::storeEntry"); |
| 450 | std::lock_guard<std::mutex> guard(this->_pImpl->_mutex); |
| 451 | |
| 452 | // cache the request with the key |
| 453 | int status = CESIUM_SQLITE(sqlite3_reset)( |
| 454 | this->_pImpl->_storeResponseStmtWrapper.get()); |
| 455 | if (status != SQLITE_OK) { |
| 456 | SPDLOG_LOGGER_ERROR( |
| 457 | this->_pImpl->_pLogger, |
| 458 | CESIUM_SQLITE(sqlite3_errstr)(status)); |
| 459 | return false; |
| 460 | } |
| 461 | |
| 462 | status = CESIUM_SQLITE(sqlite3_clear_bindings)( |
| 463 | this->_pImpl->_storeResponseStmtWrapper.get()); |
| 464 | if (status != SQLITE_OK) { |
| 465 | SPDLOG_LOGGER_ERROR( |
| 466 | this->_pImpl->_pLogger, |
| 467 | CESIUM_SQLITE(sqlite3_errstr)(status)); |
| 468 | return false; |
| 469 | } |
| 470 | |
| 471 | status = CESIUM_SQLITE(sqlite3_bind_int64)( |
| 472 | this->_pImpl->_storeResponseStmtWrapper.get(), |
| 473 | 1, |
| 474 | static_cast<int64_t>(expiryTime)); |
| 475 | if (status != SQLITE_OK) { |
| 476 | SPDLOG_LOGGER_ERROR( |
| 477 | this->_pImpl->_pLogger, |
| 478 | CESIUM_SQLITE(sqlite3_errstr)(status)); |
| 479 | return false; |
| 480 | } |
| 481 | |
| 482 | status = CESIUM_SQLITE(sqlite3_bind_int64)( |
| 483 | this->_pImpl->_storeResponseStmtWrapper.get(), |
| 484 | 2, |
| 485 | static_cast<int64_t>(std::time(nullptr))); |
| 486 | if (status != SQLITE_OK) { |
| 487 | SPDLOG_LOGGER_ERROR( |
| 488 | this->_pImpl->_pLogger, |
| 489 | CESIUM_SQLITE(sqlite3_errstr)(status)); |
| 490 | return false; |
| 491 | } |
| 492 | |
| 493 | std::string responseHeaderString = convertHeadersToString(responseHeaders); |
| 494 | status = CESIUM_SQLITE(sqlite3_bind_text)( |
| 495 | this->_pImpl->_storeResponseStmtWrapper.get(), |
| 496 | 3, |
| 497 | responseHeaderString.c_str(), |
no test coverage detected