MCPcopy Create free account
hub / github.com/CesiumGS/cesium-native / storeEntry

Method storeEntry

CesiumAsync/src/SqliteCache.cpp:440–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438}
439
440bool 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(),

Callers 1

getMethod · 0.45

Calls 5

CESIUM_SQLITEClass · 0.85
convertHeadersToStringFunction · 0.85
getMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected