@@ -33,6 +33,9 @@ class BasicCCDBManager
3333 struct CachedObject {
3434 std::shared_ptr<void > objPtr;
3535 std::string uuid;
36+ long startvalidity = 0 ;
37+ long endvalidity = 0 ;
38+ bool isValid (long ts) { return ts < endvalidity && ts > startvalidity; }
3639 };
3740
3841 public:
@@ -92,6 +95,12 @@ class BasicCCDBManager
9295 }
9396 }
9497
98+ // / check if checks of object validity before CCDB query is enabled
99+ bool isValidityCheckingEnabled () const { return mCheckObjValidityEnabled ; }
100+
101+ // / set the flag to check object validity before CCDB query
102+ void setValidityCheckingEnabled (bool v = true ) { mCheckObjValidityEnabled = v; }
103+
95104 // / set the object upper validity limit
96105 void setCreatedNotAfter (long v) { mCreatedNotAfter = v; }
97106
@@ -124,6 +133,7 @@ class BasicCCDBManager
124133 long mTimestamp {o2::ccdb::getCurrentTimestamp ()}; // timestamp to be used for query (by default "now")
125134 bool mCanDefault = false ; // whether default is ok --> useful for testing purposes done standalone/isolation
126135 bool mCachingEnabled = true ; // whether caching is enabled
136+ bool mCheckObjValidityEnabled = false ; // wether the validity of cached object is checked before proceeding to a CCDB API query
127137 long mCreatedNotAfter = 0 ; // upper limit for object creation timestamp (TimeMachine mode) - If-Not-After HTTP header
128138 long mCreatedNotBefore = 0 ; // lower limit for object creation timestamp (TimeMachine mode) - If-Not-Before HTTP header
129139};
@@ -143,6 +153,8 @@ T* BasicCCDBManager::getForTimeStamp(std::string const& path, long timestamp)
143153 if (ptr) { // new object was shipped, old one (if any) is not valid anymore
144154 cached.objPtr .reset (ptr);
145155 cached.uuid = mHeaders [" ETag" ];
156+ cached.startvalidity = std::stol (mMetaData [" Valid-From" ]);
157+ cached.endvalidity = std::stol (mMetaData [" Valid-Until" ]);
146158 } else if (mHeaders .count (" Error" )) { // in case of errors the pointer is 0 and headers["Error"] should be set
147159 clearCache (path); // in case of any error clear cache for this object
148160 } else { // the old object is valid
0 commit comments