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

Method getEntry

CesiumAsync/src/SqliteCache.cpp:293–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291SqliteCache::~SqliteCache() = default;
292
293std::optional<CacheItem> SqliteCache::getEntry(const std::string& key) const {
294 CESIUM_TRACE("SqliteCache::getEntry");
295 std::lock_guard<std::mutex> guard(this->_pImpl->_mutex);
296
297 // get entry based on key
298 int status =
299 CESIUM_SQLITE(sqlite3_reset)(this->_pImpl->_getEntryStmtWrapper.get());
300 if (status != SQLITE_OK) {
301 SPDLOG_LOGGER_ERROR(
302 this->_pImpl->_pLogger,
303 CESIUM_SQLITE(sqlite3_errstr)(status));
304 return std::nullopt;
305 }
306
307 status = CESIUM_SQLITE(sqlite3_clear_bindings)(
308 this->_pImpl->_getEntryStmtWrapper.get());
309 if (status != SQLITE_OK) {
310 SPDLOG_LOGGER_ERROR(
311 this->_pImpl->_pLogger,
312 CESIUM_SQLITE(sqlite3_errstr)(status));
313 return std::nullopt;
314 }
315
316 status = CESIUM_SQLITE(sqlite3_bind_text)(
317 this->_pImpl->_getEntryStmtWrapper.get(),
318 1,
319 key.c_str(),
320 -1,
321 SQLITE_STATIC);
322 if (status != SQLITE_OK) {
323 SPDLOG_LOGGER_ERROR(
324 this->_pImpl->_pLogger,
325 CESIUM_SQLITE(sqlite3_errstr)(status));
326 return std::nullopt;
327 }
328
329 status =
330 CESIUM_SQLITE(sqlite3_step)(this->_pImpl->_getEntryStmtWrapper.get());
331 if (status == SQLITE_DONE) {
332 // Cache miss
333 return std::nullopt;
334 }
335
336 if (status != SQLITE_ROW) {
337 // Something went wrong.
338 SPDLOG_LOGGER_ERROR(
339 this->_pImpl->_pLogger,
340 CESIUM_SQLITE(sqlite3_errstr)(status));
341 return std::nullopt;
342 }
343
344 // Cache hit - unpack and return it.
345 const int64_t itemIndex = CESIUM_SQLITE(
346 sqlite3_column_int64)(this->_pImpl->_getEntryStmtWrapper.get(), 0);
347
348 // parse cache item metadata
349 const std::time_t expiryTime = CESIUM_SQLITE(
350 sqlite3_column_int64)(this->_pImpl->_getEntryStmtWrapper.get(), 1);

Callers 1

getMethod · 0.45

Calls 3

CESIUM_SQLITEClass · 0.85
convertStringToHeadersFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected