/** @var int Key fetched */
private $warmupKeyMisses = 0;
+ /** @var float|null */
+ private $wallClockOverride;
+
/** Max time expected to pass between delete() and DB commit finishing */
const MAX_COMMIT_DELAY = 3;
/** Max replication+snapshot lag before applying TTL_LAGGED or disallowing set() */
return isset( $parts[1] ) ? $parts[1] : $parts[0]; // sanity
}
- /**
- * @return float UNIX timestamp
- * @codeCoverageIgnore
- */
- protected function getCurrentTime() {
- return microtime( true );
- }
-
/**
* @param string $value Wrapped value like "PURGED:<timestamp>:<holdoff>"
* @return array|bool Array containing a UNIX timestamp (float) and holdoff period (integer),
return $warmupCache;
}
+
+ /**
+ * @return float UNIX timestamp
+ * @codeCoverageIgnore
+ */
+ protected function getCurrentTime() {
+ return $this->wallClockOverride ?: microtime( true );
+ }
+
+ /**
+ * @param float|null &$time Mock UNIX timestamp for testing
+ * @codeCoverageIgnore
+ */
+ public function setMockTime( &$time ) {
+ $this->wallClockOverride =& $time;
+ $this->cache->setMockTime( $time );
+ }
}