MCPcopy Create free account
hub / github.com/Kitware/VTK / tryGet

Method tryGet

ThirdParty/libproj/vtklibproj/src/networkfilemanager.cpp:1170–1206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1168// ---------------------------------------------------------------------------
1169
1170bool NetworkFilePropertiesCache::tryGet(PJ_CONTEXT *ctx, const std::string &url,
1171 FileProperties &props) {
1172 if (cache_.tryGet(url, props)) {
1173 return true;
1174 }
1175
1176 auto diskCache = DiskChunkCache::open(ctx);
1177 if (!diskCache)
1178 return false;
1179 auto stmt =
1180 diskCache->prepare("SELECT lastChecked, fileSize, lastModified, etag "
1181 "FROM properties WHERE url = ?");
1182 if (!stmt)
1183 return false;
1184 stmt->bindText(url.c_str());
1185 if (stmt->execute() != SQLITE_ROW) {
1186 return false;
1187 }
1188 props.lastChecked = stmt->getInt64();
1189 props.size = stmt->getInt64();
1190 const char *lastModified = stmt->getText();
1191 props.lastModified = lastModified ? lastModified : std::string();
1192 const char *etag = stmt->getText();
1193 props.etag = etag ? etag : std::string();
1194
1195 const auto ttl = pj_context_get_grid_cache_ttl(ctx);
1196 if (ttl > 0) {
1197 time_t curTime;
1198 time(&curTime);
1199 if (curTime > props.lastChecked + ttl) {
1200 props = FileProperties();
1201 return false;
1202 }
1203 }
1204 cache_.insert(url, props);
1205 return true;
1206}
1207
1208// ---------------------------------------------------------------------------
1209

Callers 7

getMethod · 0.45
getMethod · 0.45
getHandleMethod · 0.45
getFromCacheMethod · 0.45
getGridInfoFromCacheMethod · 0.45
getAliasesMethod · 0.45

Calls 10

FilePropertiesClass · 0.85
prepareMethod · 0.80
bindTextMethod · 0.80
getInt64Method · 0.80
getTextMethod · 0.80
stringClass · 0.50
c_strMethod · 0.45
executeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected