* @ingroup Cache
* @since 1.26
*/
-class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
+class WANObjectCache implements IExpiringStore, IStoreKeyEncoder, LoggerAwareInterface {
/** @var BagOStuff The local datacenter cache */
protected $cache;
/** @var MapCacheLRU[] Map of group PHP instance caches */
[ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
);
// Case C: medium length request with medium replication lag
+ } elseif ( $lockTSE >= 0 ) {
+ // Store value as *almost* stale to avoid cache and mutex stampedes
+ $logicalTTL = self::TTL_SECOND;
+ $this->logger->info(
+ 'Lowered set() TTL for {cachekey} due to high read lag.',
+ [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
+ );
} else {
- if ( $lockTSE >= 0 ) {
- // Store value as *almost* stale to avoid cache and mutex stampedes
- $logicalTTL = self::TTL_SECOND;
- $this->logger->info(
- 'Lowered set() TTL for {cachekey} due to high read lag.',
- [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
- );
- } else {
- $this->logger->info(
- 'Rejected set() for {cachekey} due to high read lag.',
- [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
- );
+ $this->logger->info(
+ 'Rejected set() for {cachekey} due to high read lag.',
+ [ 'cachekey' => $key, 'lag' => $lag, 'age' => $age ]
+ );
- return true; // no-op the write for being unsafe
- }
+ return true; // no-op the write for being unsafe
}
}
* @param string $kClass
* @param float $elapsed Seconds spent regenerating the value
* @param float $lockTSE
- * @param $hasLock bool
+ * @param bool $hasLock
* @return bool Whether it is OK to proceed with a key set operation
*/
private function checkAndSetCooloff( $key, $kClass, $elapsed, $lockTSE, $hasLock ) {
* @return string A collection name to describe this class of key
*/
protected function determineKeyClassForStats( $key ) {
- $parts = explode( ':', $key );
+ $parts = explode( ':', $key, 3 );
return $parts[1] ?? $parts[0]; // sanity
}