You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by br...@apache.org on 2015/05/01 09:13:05 UTC

trafficserver git commit: Adding new API to C++ api for Cache Status

Repository: trafficserver
Updated Branches:
  refs/heads/master 31c544114 -> 523b47493


Adding new API to C++ api for Cache Status


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/523b4749
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/523b4749
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/523b4749

Branch: refs/heads/master
Commit: 523b47493b446bcacb69102cbb6b9e9a498b584d
Parents: 31c5441
Author: Brian Geffon <br...@apache.org>
Authored: Thu Apr 30 11:07:42 2015 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Thu Apr 30 11:07:42 2015 -0700

----------------------------------------------------------------------
 lib/atscppapi/src/Transaction.cc                | 23 ++++++++++++++++++++
 .../src/include/atscppapi/Transaction.h         | 13 +++++++++++
 2 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/523b4749/lib/atscppapi/src/Transaction.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/Transaction.cc b/lib/atscppapi/src/Transaction.cc
index 4ff6319..9254d8c 100644
--- a/lib/atscppapi/src/Transaction.cc
+++ b/lib/atscppapi/src/Transaction.cc
@@ -303,6 +303,29 @@ Transaction::setTimeout(Transaction::TimeoutType type, int time_ms)
   }
 }
 
+
+Transaction::CacheStatus
+Transaction::getCacheStatus() {
+  int obj_status = TS_ERROR;
+
+  if (TSHttpTxnCacheLookupStatusGet(state_->txn_, &obj_status) == TS_ERROR) {
+    return CACHE_LOOKUP_NONE;
+  }
+
+  switch (obj_status) {
+  case TS_CACHE_LOOKUP_MISS:
+    return CACHE_LOOKUP_MISS;
+  case TS_CACHE_LOOKUP_HIT_STALE:
+    return CACHE_LOOKUP_HIT_STALE;
+  case TS_CACHE_LOOKUP_HIT_FRESH:
+    return CACHE_LOOKUP_HIT_FRESH;
+  case TS_CACHE_LOOKUP_SKIPPED:
+    return CACHE_LOOKUP_SKIPED;
+  default:
+    return CACHE_LOOKUP_NONE;
+  }
+}
+
 void
 Transaction::redirectTo(std::string const &url)
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/523b4749/lib/atscppapi/src/include/atscppapi/Transaction.h
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/include/atscppapi/Transaction.h b/lib/atscppapi/src/include/atscppapi/Transaction.h
index a0d7bf7..39454b0 100644
--- a/lib/atscppapi/src/include/atscppapi/Transaction.h
+++ b/lib/atscppapi/src/include/atscppapi/Transaction.h
@@ -255,6 +255,19 @@ public:
   void setTimeout(TimeoutType type, int time_ms);
 
   /**
+   * Represents different states of an object served out of the cache
+   */
+  enum CacheStatus {
+    CACHE_LOOKUP_MISS = 0,      /**< The object was not found in the cache */
+    CACHE_LOOKUP_HIT_STALE,     /**< The object was found in cache but stale */
+    CACHE_LOOKUP_HIT_FRESH,     /**< The object was found in cache and was fresh */
+    CACHE_LOOKUP_SKIPED,        /**< Cache lookup was not performed */
+    CACHE_LOOKUP_NONE
+  };
+
+  CacheStatus getCacheStatus();
+
+  /**
    * Returns the TSHttpTxn related to the current Transaction
    *
    * @return a void * which can be cast back to a TSHttpTxn.