MCPcopy Create free account
hub / github.com/apache/trafficserver / appendCacheKey

Function appendCacheKey

plugins/prefetch/plugin.cc:211–238  ·  view source on GitHub ↗

* @brief Get the cachekey used for the particular object in this transaction. * * @param txnp HTTP transaction structure * @param reqBuffer request TSMBuffer * @param destination string reference to where the result is to be appended. * @return true if success or false if failure */

Source from the content-addressed store, hash-verified

209 * @return true if success or false if failure
210 */
211bool
212appendCacheKey(const TSHttpTxn txnp, const TSMBuffer reqBuffer, String &key)
213{
214 bool ret = false;
215 TSMLoc keyLoc = TS_NULL_MLOC;
216 if (TS_SUCCESS == TSUrlCreate(reqBuffer, &keyLoc)) {
217 if (TS_SUCCESS == TSHttpTxnCacheLookupUrlGet(txnp, reqBuffer, keyLoc)) {
218 int urlLen = 0;
219 char *url = TSUrlStringGet(reqBuffer, keyLoc, &urlLen);
220 if (nullptr != url) {
221 key.append(url, urlLen);
222 PrefetchDebug("cache key: %s", key.c_str());
223 TSfree(static_cast<void *>(url));
224 ret = true;
225 }
226 } else {
227 PrefetchDebug("Failure lookup up cache url");
228 }
229 TSHandleMLocRelease(reqBuffer, TS_NULL_MLOC, keyLoc);
230 } else {
231 PrefetchDebug("Failure creating url");
232 }
233
234 if (!ret) {
235 PrefetchError("failed to get cache key");
236 }
237 return ret;
238}
239
240/**
241 * @brief Find out if the object was found fresh in cache.

Callers 1

contHandleFetchFunction · 0.85

Calls 7

TSUrlCreateFunction · 0.85
TSUrlStringGetFunction · 0.85
TSfreeFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
appendMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected