255 $this->
cache = $params[
'cache'];
256 $this->region =
$params[
'region'] ??
'main';
257 $this->cluster =
$params[
'cluster'] ??
'wan-main';
258 $this->mcrouterAware = !empty(
$params[
'mcrouterAware'] );
259 $this->epoch =
$params[
'epoch'] ?? 1.0;
263 $this->asyncHandler =
$params[
'asyncHandler'] ??
null;
270 $this->logger = $logger;
331 final public function get(
332 $key, &$curTTL =
null,
array $checkKeys = [], &$info =
null
334 $curTTLs = self::PASS_BY_REF;
335 $infoByKey = self::PASS_BY_REF;
336 $values = $this->
getMulti( [ $key ], $curTTLs, $checkKeys, $infoByKey );
337 $curTTL = $curTTLs[$key] ??
null;
338 if ( $info === self::PASS_BY_REF ) {
340 'asOf' => $infoByKey[$key][
'asOf'] ??
null,
341 'tombAsOf' => $infoByKey[$key][
'tombAsOf'] ??
null,
342 'lastCKPurge' => $infoByKey[$key][
'lastCKPurge'] ??
null
345 $info = $infoByKey[$key][
'asOf'] ??
null;
348 return $values[$key] ??
false;
373 array $checkKeys = [],
380 $vPrefixLen =
strlen( self::VALUE_KEY_PREFIX );
381 $valueKeys = self::prefixCacheKeys(
$keys, self::VALUE_KEY_PREFIX );
383 $checkKeysForAll = [];
384 $checkKeysByKey = [];
386 foreach ( $checkKeys as $i => $checkKeyGroup ) {
387 $prefixed = self::prefixCacheKeys( (
array)$checkKeyGroup, self::TIME_KEY_PREFIX );
388 $checkKeysFlat =
array_merge( $checkKeysFlat, $prefixed );
391 $checkKeysForAll =
array_merge( $checkKeysForAll, $prefixed );
398 $keysGet =
array_merge( $valueKeys, $checkKeysFlat );
399 if ( $this->warmupCache ) {
402 $this->warmupKeyMisses += count( $keysGet );
407 $wrappedValues += $this->
cache->getMulti( $keysGet );
413 $purgeValuesForAll = $this->
processCheckKeys( $checkKeysForAll, $wrappedValues, $now );
414 $purgeValuesByKey = [];
415 foreach ( $checkKeysByKey as $cacheKey => $checks ) {
416 $purgeValuesByKey[$cacheKey] =
421 foreach ( $valueKeys as $vKey ) {
422 $key =
substr( $vKey, $vPrefixLen );
423 list(
$value, $curTTL, $asOf, $tombAsOf ) =
isset( $wrappedValues[$vKey] )
424 ? $this->
unwrap( $wrappedValues[$vKey], $now )
425 : [
false,
null,
null,
null ];
429 if (
isset( $purgeValuesByKey[$key] ) ) {
430 $purgeValues =
array_merge( $purgeValues, $purgeValuesByKey[$key] );
434 foreach ( $purgeValues as $purge ) {
435 $lastCKPurge =
max( $purge[self::FLD_TIME], $lastCKPurge );
436 $safeTimestamp = $purge[self::FLD_TIME] + $purge[self::FLD_HOLDOFF];
437 if (
$value !==
false && $safeTimestamp >= $asOf ) {
439 $ago = min( $purge[self::FLD_TIME] - $now, self::TINY_NEGATIVE );
441 $curTTL = min( $curTTL, $ago );
448 if ( $curTTL !==
null ) {
452 $infoByKey[$key] = ( $info === self::PASS_BY_REF )
453 ? [
'asOf' => $asOf,
'tombAsOf' => $tombAsOf,
'lastCKPurge' => $lastCKPurge ]
471 foreach ( $timeKeys as $timeKey ) {
472 $purge =
isset( $wrappedValues[$timeKey] )
475 if ( $purge ===
false ) {
478 $this->
cache->add( $timeKey, $newVal, self::CHECK_KEY_TTL );
554 final public function set( $key,
$value, $ttl = self::TTL_INDEFINITE,
array $opts = [] ) {
556 $lockTSE = $opts[
'lockTSE'] ?? self::TSE_NONE;
557 $staleTTL = $opts[
'staleTTL'] ?? self::STALE_TTL_NONE;
558 $age =
isset( $opts[
'since'] ) ?
max( 0, $now - $opts[
'since'] ) : 0;
559 $creating = $opts[
'creating'] ??
false;
560 $lag = $opts[
'lag'] ?? 0;
563 if ( !empty( $opts[
'pending'] ) ) {
565 'Rejected set() for {cachekey} due to pending writes.',
566 [
'cachekey' => $key ]
574 if ( $lag ===
false || ( $lag + $age ) > self::MAX_READ_LAG ) {
576 if ( $age > self::MAX_READ_LAG ) {
577 if ( $lockTSE >= 0 ) {
579 $logicalTTL = self::TTL_SECOND;
581 'Lowered set() TTL for {cachekey} due to snapshot lag.',
582 [
'cachekey' => $key,
'lag' => $lag,
'age' => $age ]
586 'Rejected set() for {cachekey} due to snapshot lag.',
587 [
'cachekey' => $key,
'lag' => $lag,
'age' => $age ]
593 }
elseif ( $lag ===
false || $lag > self::MAX_READ_LAG ) {
594 if ( $lockTSE >= 0 ) {
595 $logicalTTL = min( $ttl ?:
INF, self::TTL_LAGGED );
597 $ttl = min( $ttl ?:
INF, self::TTL_LAGGED );
599 $this->logger->warning(
600 'Lowered set() TTL for {cachekey} due to replication lag.',
601 [
'cachekey' => $key,
'lag' => $lag,
'age' => $age ]
604 }
elseif ( $lockTSE >= 0 ) {
606 $logicalTTL = self::TTL_SECOND;
608 'Lowered set() TTL for {cachekey} due to high read lag.',
609 [
'cachekey' => $key,
'lag' => $lag,
'age' => $age ]
613 'Rejected set() for {cachekey} due to high read lag.',
614 [
'cachekey' => $key,
'lag' => $lag,
'age' => $age ]
626 $ok = $this->
cache->add( self::VALUE_KEY_PREFIX . $key, $wrapped, $storeTTL );
628 $ok = $this->
cache->merge(
629 self::VALUE_KEY_PREFIX . $key,
630 function (
$cache, $key, $cWrapped )
use ( $wrapped ) {
703 final public function delete( $key, $ttl = self::HOLDOFF_TTL ) {
706 $ok = $this->
relayDelete( self::VALUE_KEY_PREFIX . $key );
709 $ok = $this->
relayPurge( self::VALUE_KEY_PREFIX . $key, $ttl, self::HOLDOFF_NONE );
713 $this->stats->increment(
"wanobjectcache.$kClass.delete." . ( $ok ?
'ok' :
'error' ) );
804 foreach (
$keys as $key ) {
805 $rawKeys[$key] = self::TIME_KEY_PREFIX . $key;
808 $rawValues = $this->
cache->getMulti( $rawKeys );
812 foreach ( $rawKeys as $key => $rawKey ) {
814 if ( $purge !==
false ) {
815 $time = $purge[self::FLD_TIME];
827 $times[$key] =
$time;
869 $ok = $this->
relayPurge( self::TIME_KEY_PREFIX . $key, self::CHECK_KEY_TTL, $holdoff );
872 $this->stats->increment(
"wanobjectcache.$kClass.ck_touch." . ( $ok ?
'ok' :
'error' ) );
906 $ok = $this->
relayDelete( self::TIME_KEY_PREFIX . $key );
909 $this->stats->increment(
"wanobjectcache.$kClass.ck_reset." . ( $ok ?
'ok' :
'error' ) );
1216 $pcTTL = $opts[
'pcTTL'] ?? self::TTL_UNCACHEABLE;
1221 if ( $pcTTL >= 0 && $this->callbackDepth == 0 ) {
1222 $group = $opts[
'pcGroup'] ?? self::PC_PRIMARY;
1224 $value = $procCache->has( $key, $pcTTL ) ? $procCache->get( $key ) :
false;
1230 if (
$value ===
false ) {
1232 if (
isset( $opts[
'version'] ) ) {
1233 $version = $opts[
'version'];
1238 function ( $oldValue, &$ttl, &$setOpts, $oldAsOf )
1239 use ( $callback, $version ) {
1243 && $oldValue[self::VFLD_VERSION] === $version
1245 $oldData = $oldValue[self::VFLD_DATA];
1253 self::VFLD_DATA => $callback( $oldData, $ttl, $setOpts, $oldAsOf ),
1254 self::VFLD_VERSION => $version
1260 if ( $cur[self::VFLD_VERSION] === $version ) {
1262 $value = $cur[self::VFLD_DATA];
1271 [
'version' =>
null,
'minAsOf' => $asOf ] + $opts
1279 if ( $procCache &&
$value !==
false ) {
1280 $procCache->set( $key,
$value );
1301 $lowTTL = $opts[
'lowTTL'] ?? min( self::LOW_TTL, $ttl );
1302 $lockTSE = $opts[
'lockTSE'] ?? self::TSE_NONE;
1303 $staleTTL = $opts[
'staleTTL'] ?? self::STALE_TTL_NONE;
1304 $graceTTL = $opts[
'graceTTL'] ?? self::GRACE_TTL_NONE;
1305 $checkKeys = $opts[
'checkKeys'] ?? [];
1306 $busyValue = $opts[
'busyValue'] ??
null;
1307 $popWindow = $opts[
'hotTTR'] ?? self::HOT_TTR;
1308 $ageNew = $opts[
'ageNew'] ?? self::AGE_NEW;
1309 $minTime = $opts[
'minAsOf'] ?? self::MIN_TIMESTAMP_NONE;
1310 $needsVersion =
isset( $opts[
'version'] );
1311 $touchedCb = $opts[
'touchedCallback'] ??
null;
1317 $curTTL = self::PASS_BY_REF;
1318 $curInfo = self::PASS_BY_REF;
1321 list( $curTTL, $LPT ) = $this->
resolveCTL( $curValue, $curTTL, $curInfo, $touchedCb );
1324 $asOf = $curInfo[
'asOf'];
1331 $preemptiveRefresh = (
1336 if ( !$preemptiveRefresh ) {
1337 $this->stats->increment(
"wanobjectcache.$kClass.hit.good" );
1341 $this->stats->increment(
"wanobjectcache.$kClass.hit.refresh" );
1347 $isKeyTombstoned = ( $curInfo[
'tombAsOf'] !==
null );
1348 if ( $isKeyTombstoned ) {
1358 $this->
isValid(
$value, $needsVersion, $asOf, $minTime, $LPT ) &&
1361 $this->stats->increment(
"wanobjectcache.$kClass.hit.volatile" );
1377 ( $curTTL !==
null && $curTTL <= 0 &&
abs( $curTTL ) <=
$lockTSE ) ||
1380 ( $busyValue !==
null &&
$value ===
false );
1385 if ( $this->
cache->add( self::MUTEX_KEY_PREFIX . $key, 1, self::LOCK_TTL ) ) {
1390 $this->stats->increment(
"wanobjectcache.$kClass.hit.stale" );
1395 if ( $busyValue !==
null ) {
1397 $miss =
is_infinite( $minTime ) ?
'renew' :
'miss';
1398 $this->stats->increment(
"wanobjectcache.$kClass.$miss.busy" );
1406 throw new InvalidArgumentException(
"Invalid cache miss callback provided." );
1412 ++$this->callbackDepth;
1416 --$this->callbackDepth;
1418 $valueIsCacheable = (
$value !==
false && $ttl >= 0 );
1420 if ( $valueIsCacheable ) {
1422 $this->stats->timing(
"wanobjectcache.$kClass.regen_set_delay", 1000 * $ago );
1424 if ( $isKeyTombstoned ) {
1427 $tempTTL =
max( self::INTERIM_KEY_TTL, (
int)$lockTSE );
1430 }
elseif ( !$useMutex || $hasLock ) {
1432 $setOpts[
'creating'] = ( $curValue ===
false );
1445 $this->
cache->changeTTL( self::MUTEX_KEY_PREFIX . $key, (
int)$initialTime - 60 );
1448 $miss =
is_infinite( $minTime ) ?
'renew' :
'miss';
1449 $this->stats->increment(
"wanobjectcache.$kClass.$miss.compute" );
1459 return ( $age <
mt_rand( self::RECENT_SET_LOW_MS, self::RECENT_SET_HIGH_MS ) / 1e3 );
1477 if ( $lockTSE < 0 || $hasLock ) {
1479 }
elseif ( $elapsed <= self::SET_DELAY_HIGH_MS * 1e3 ) {
1483 $this->
cache->clearLastError();
1485 !$this->
cache->add( self::COOLOFF_KEY_PREFIX . $key, 1, self::COOLOFF_TTL ) &&
1489 $this->stats->increment(
"wanobjectcache.$kClass.cooloff_bounce" );
1506 if ( $touchedCallback ===
null ||
$value ===
false ) {
1507 return [
$curTTL,
max( $curInfo[
'tombAsOf'], $curInfo[
'lastCKPurge'] ) ];
1511 throw new InvalidArgumentException(
"Invalid expiration callback provided." );
1515 if ( $touched !==
null && $touched >= $curInfo[
'asOf'] ) {
1516 $curTTL = min( $curTTL, self::TINY_NEGATIVE, $curInfo[
'asOf'] - $touched );
1519 return [
$curTTL,
max( $curInfo[
'tombAsOf'], $curInfo[
'lastCKPurge'], $touched ) ];
1530 if ( $touchedCallback ===
null ||
$value ===
false ) {
1535 throw new InvalidArgumentException(
"Invalid expiration callback provided." );
1549 return [
false,
null ];
1552 $wrapped = $this->
cache->get( self::INTERIM_KEY_PREFIX . $key );
1554 $valueAsOf = $wrapped[self::FLD_TIME] ??
null;
1555 if ( $this->
isValid(
$value, $versioned, $valueAsOf, $minTime ) ) {
1559 return [
false,
null ];
1569 $wrapped = $this->
wrap(
$value, $tempTTL, $newAsOf );
1571 $this->
cache->merge(
1572 self::INTERIM_KEY_PREFIX . $key,
1573 function () use ( $wrapped ) {
1648 ArrayIterator $keyedIds, $ttl, callable $callback,
array $opts = []
1650 $valueKeys =
array_keys( $keyedIds->getArrayCopy() );
1651 $checkKeys = $opts[
'checkKeys'] ?? [];
1652 $pcTTL = $opts[
'pcTTL'] ?? self::TTL_UNCACHEABLE;
1659 $this->warmupKeyMisses = 0;
1664 return $callback( $id, $oldValue, $ttl, $setOpts, $oldAsOf );
1668 foreach ( $keyedIds as $key => $id ) {
1672 $this->warmupCache = [];
1743 ArrayIterator $keyedIds, $ttl, callable $callback,
array $opts = []
1745 $idsByValueKey = $keyedIds->getArrayCopy();
1747 $checkKeys = $opts[
'checkKeys'] ?? [];
1748 $pcTTL = $opts[
'pcTTL'] ?? self::TTL_UNCACHEABLE;
1749 unset( $opts[
'lockTSE'] );
1750 unset( $opts[
'busyValue'] );
1755 $this->warmupKeyMisses = 0;
1763 $curByKey = $this->
getMulti( $keysGet, $curTTLs, $checkKeys, $asOfs );
1764 foreach ( $keysGet as $key ) {
1766 $idsRegen[] = $idsByValueKey[$key];
1773 $newValsById = $idsRegen ? $callback( $idsRegen, $newTTLsById, $newSetOpts ) : [];
1778 use ( $callback, &$id, $newValsById, $newTTLsById, $newSetOpts )
1782 $newValue = $newValsById[$id];
1783 $ttl = $newTTLsById[$id];
1788 $ttls = [ $id => $ttl ];
1789 $newValue = $callback( [ $id ], $ttls, $setOpts )[$id];
1798 foreach ( $idsByValueKey as $key => $id ) {
1802 $this->warmupCache = [];
1819 final public function reap( $key, $purgeTimestamp, &$isStale =
false ) {
1820 $minAsOf = $purgeTimestamp + self::HOLDOFF_TTL;
1821 $wrapped = $this->
cache->get( self::VALUE_KEY_PREFIX . $key );
1822 if (
is_array( $wrapped ) && $wrapped[self::FLD_TIME] < $minAsOf ) {
1824 $this->logger->warning(
"Reaping stale value key '$key'." );
1825 $ttlReap = self::HOLDOFF_TTL;
1826 $ok = $this->
cache->changeTTL( self::VALUE_KEY_PREFIX . $key, $ttlReap );
1828 $this->logger->error(
"Could not complete reap of key '$key'." );
1848 final public function reapCheckKey( $key, $purgeTimestamp, &$isStale =
false ) {
1850 if ( $purge && $purge[self::FLD_TIME] < $purgeTimestamp ) {
1852 $this->logger->warning(
"Reaping stale check key '$key'." );
1853 $ok = $this->
cache->changeTTL( self::TIME_KEY_PREFIX . $key, self::TTL_SECOND );
1855 $this->logger->error(
"Could not complete reap of check key '$key'." );
1873 public function makeKey( $class, $component =
null ) {
1896 foreach ( $entities as $entity ) {
1911 return self::ERR_NONE;
1913 return self::ERR_NO_RESPONSE;
1915 return self::ERR_UNREACHABLE;
1917 return self::ERR_UNEXPECTED;
1925 $this->
cache->clearLastError();
1934 $this->processCaches = [];
1967 return $this->
cache->getQoS( $flag );
2033 public function adaptiveTTL( $mtime, $maxTTL, $minTTL = 30, $factor = 0.2 ) {
2035 $mtime = (
int)$mtime;
2038 if ( !
is_int( $mtime ) || $mtime <= 0 ) {
2044 return (
int)min( $maxTTL,
max( $minTTL, $factor * $age ) );
2052 return $this->warmupKeyMisses;
2066 if ( $this->mcrouterAware ) {
2069 $ok = $this->
cache->set(
2070 "/*/{$this->cluster}/{$key}",
2076 $ok = $this->
cache->set(
2093 if ( $this->mcrouterAware ) {
2096 $ok = $this->
cache->delete(
"/*/{$this->cluster}/{$key}" );
2099 $ok = $this->
cache->delete( $key );
2113 if ( !$this->asyncHandler ) {
2117 $func = $this->asyncHandler;
2118 $func(
function () use ( $key, $ttl, $callback, $opts ) {
2120 $opts[
'minAsOf'] =
INF;
2141 if ( $curTTL > 0 ) {
2143 }
elseif ( $graceTTL <= 0 ) {
2147 $ageStale =
abs( $curTTL );
2149 if ( $curGTTL <= 0 ) {
2171 if ( $lowTTL <= 0 ) {
2173 }
elseif ( $curTTL >= $lowTTL ) {
2175 }
elseif ( $curTTL <= 0 ) {
2179 $chance = ( 1 - $curTTL /
$lowTTL );
2200 if ( $ageNew < 0 || $timeTillRefresh <= 0 ) {
2204 $age = $now -
$asOf;
2206 if ( $timeOld <= 0 ) {
2213 $refreshWindowSec =
max( $timeTillRefresh - $ageNew - self::RAMPUP_TTL / 2, 1 );
2220 $chance *= ( $timeOld <= self::RAMPUP_TTL ) ? $timeOld / self::RAMPUP_TTL : 1;
2235 protected function isValid(
$value, $versioned, $asOf, $minTime, $purgeTime =
null ) {
2237 $safeMinTime =
max( $minTime, $purgeTime + self::TINY_POSTIVE );
2239 if (
$value ===
false ) {
2243 }
elseif ( $safeMinTime > 0 && $asOf < $minTime ) {
2260 self::FLD_VERSION => self::VERSION,
2261 self::FLD_VALUE =>
$value,
2262 self::FLD_TTL => $ttl,
2263 self::FLD_TIME =>
$now
2276 protected function unwrap( $wrapped, $now ) {
2279 if ( $purge !==
false ) {
2281 $curTTL = min( $purge[self::FLD_TIME] - $now, self::TINY_NEGATIVE );
2282 return [
false,
$curTTL,
null, $purge[self::FLD_TIME] ];
2286 || !
isset( $wrapped[self::FLD_VERSION] )
2287 || $wrapped[self::FLD_VERSION] !== self::VERSION
2289 return [
false,
null,
null,
null ];
2292 if ( $wrapped[self::FLD_TTL] > 0 ) {
2294 $age = $now - $wrapped[self::FLD_TIME];
2295 $curTTL =
max( $wrapped[self::FLD_TTL] - $age, 0.0 );
2301 if ( $wrapped[self::FLD_TIME] < $this->epoch ) {
2303 return [
false,
null,
null,
null ];
2306 return [ $wrapped[self::FLD_VALUE],
$curTTL, $wrapped[self::FLD_TIME],
null ];
2316 foreach (
$keys as $key ) {
2317 $res[] = $prefix . $key;
2328 $parts = explode(
':', $key );
2330 return $parts[1] ?? $parts[0];
2343 $segments = explode(
':',
$value, 3 );
2344 if ( !
isset( $segments[0] ) || !
isset( $segments[1] )
2345 ||
"{$segments[0]}:" !== self::PURGE_VAL_PREFIX
2350 if ( !
isset( $segments[2] ) ) {
2352 $segments[2] = self::HOLDOFF_TTL;
2355 if ( $segments[1] < $this->epoch ) {
2361 self::FLD_TIME => (
float)$segments[1],
2362 self::FLD_HOLDOFF => (
int)$segments[2],
2372 return self::PURGE_VAL_PREFIX . (
float)$timestamp .
':' . (
int)
$holdoff;
2380 if ( !
isset( $this->processCaches[$group] ) ) {
2381 list( , $n ) = explode(
':', $group );
2382 $this->processCaches[$group] =
new MapCacheLRU( (
int)$n );
2385 return $this->processCaches[$group];
2396 if (
isset( $opts[
'pcTTL'] ) && $opts[
'pcTTL'] > 0 && $this->callbackDepth == 0 ) {
2397 $pcGroup = $opts[
'pcGroup'] ?? self::PC_PRIMARY;
2399 foreach (
$keys as $key ) {
2400 if ( $procCache->has( $key, $pcTTL ) ) {
2401 $keysFound[] = $key;
2421 foreach (
$keys as $key ) {
2422 $keysWarmUp[] = self::VALUE_KEY_PREFIX . $key;
2425 foreach ( $checkKeys as $i => $checkKeyOrKeys ) {
2433 self::prefixCacheKeys( $checkKeyOrKeys, self::TIME_KEY_PREFIX )
2449 if ( $this->wallClockOverride ) {
2450 return $this->wallClockOverride;
2453 $clockTime = (
float)time();
2467 $this->wallClockOverride =&
$time;
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Class representing a cache/ephemeral data store.
A BagOStuff object with no objects in it.
Handles a simple LRU key/value map with a maximum number of entries.
Multi-datacenter aware caching interface.
int $callbackDepth
Callback stack depth for getWithSetCallback()
const TINY_NEGATIVE
Tiny negative float to use when CTL comes up >= 0 due to clock skew.
const HOLDOFF_TTL
Seconds to tombstone keys on delete()
const HOT_TTR
The time length of the "popularity" refresh window for hot keys.
__construct(array $params)
resolveCTL( $value, $curTTL, $curInfo, $touchedCallback)
unwrap( $wrapped, $now)
Do not use this method outside WANObjectCache.
checkAndSetCooloff( $key, $kClass, $elapsed, $lockTSE, $hasLock)
worthRefreshPopular( $asOf, $ageNew, $timeTillRefresh, $now)
Check if a key is due for randomized regeneration due to its popularity.
determineKeyClassForStats( $key)
touchCheckKey( $key, $holdoff=self::HOLDOFF_TTL)
Purge a "check" key from all datacenters, invalidating keys that use it.
adaptiveTTL( $mtime, $maxTTL, $minTTL=30, $factor=0.2)
Get a TTL that is higher for objects that have not changed recently.
string $cluster
Cache cluster name for mcrouter use.
const GRACE_TTL_NONE
Idiom for set()/getWithSetCallback() for "no post-expired grace period".
getInterimValue( $key, $versioned, $minTime)
isVolatileValueAgeNegligible( $age)
int $warmupKeyMisses
Key fetched.
float null $wallClockOverride
scheduleAsyncRefresh( $key, $ttl, $callback, $opts)
mixed[] $warmupCache
Temporary warm-up cache.
const VERSION
Cache format version number.
const TTL_UNCACHEABLE
Idiom for getWithSetCallback() callbacks to avoid calling set()
const LOW_TTL
Default remaining TTL at which to consider pre-emptive regeneration.
getMulti(array $keys, &$curTTLs=[], array $checkKeys=[], &$info=null)
Fetch the value of several keys from cache.
relayPurge( $key, $ttl, $holdoff)
Do the actual async bus purge of a key.
getLastError()
Get the "last error" registered; clearLastError() should be called manually.
BagOStuff $cache
The local datacenter cache.
getNonProcessCachedKeys(array $keys, array $opts, $pcTTL)
isValid( $value, $versioned, $asOf, $minTime, $purgeTime=null)
Check if $value is not false, versioned (if needed), and not older than $minTime (if set)
processCheckKeys(array $timeKeys, array $wrappedValues, $now)
setInterimValue( $key, $value, $tempTTL, $newAsOf)
doGetWithSetCallback( $key, $ttl, $callback, array $opts, &$asOf=null)
Do the actual I/O for getWithSetCallback() when needed.
const HOLDOFF_NONE
Idiom for delete() for "no hold-off".
const COOLOFF_TTL
Seconds to no-op key set() calls to avoid large blob I/O stampedes.
getCheckKeyTime( $key)
Fetch the value of a timestamp "check" key.
const RECENT_SET_HIGH_MS
Max millisecond set() backoff for keys in hold-off (far less than INTERIM_KEY_TTL)
relayDelete( $key)
Do the actual async bus delete of a key.
const LOCK_TTL
Seconds to keep lock keys around.
getMultiWithUnionSetCallback(ArrayIterator $keyedIds, $ttl, callable $callback, array $opts=[])
Method to fetch/regenerate multiple cache keys at once.
static prefixCacheKeys(array $keys, $prefix)
getMultiWithSetCallback(ArrayIterator $keyedIds, $ttl, callable $callback, array $opts=[])
Method to fetch multiple cache keys at once with regeneration.
const HIT_RATE_HIGH
Hits/second for a refresh to be expected within the "popularity" window.
const INTERIM_KEY_TTL
Seconds to keep interim value keys for tombstoned keys around.
static newEmpty()
Get an instance that wraps EmptyBagOStuff.
worthRefreshExpiring( $curTTL, $lowTTL)
Check if a key is nearing expiration and thus due for randomized regeneration.
getWithSetCallback( $key, $ttl, $callback, array $opts=[])
Method to fetch/regenerate cache keys.
makeMultiKeys(array $entities, callable $keyFunc)
bool $useInterimHoldOffCaching
Whether to use "interim" caching while keys are tombstoned.
const MAX_READ_LAG
Max replication+snapshot lag before applying TTL_LAGGED or disallowing set()
resolveTouched( $value, $lastPurge, $touchedCallback)
const CHECK_KEY_TTL
Seconds to keep dependency purge keys around.
const MIN_TIMESTAMP_NONE
Idiom for getWithSetCallback() for "no minimum required as-of timestamp".
useInterimHoldOffCaching( $enabled)
Enable or disable the use of brief caching for tombstoned keys.
const TINY_POSTIVE
Tiny positive float to use when using "minTime" to assert an inequality.
StatsdDataFactoryInterface $stats
clearProcessCache()
Clear the in-process caches; useful for testing.
string $region
Physical region for mcrouter use.
wrap( $value, $ttl, $now)
Do not use this method outside WANObjectCache.
float $epoch
Unix timestamp of the oldest possible valid values.
callable null $asyncHandler
Function that takes a WAN cache callback and runs it later.
const SET_DELAY_HIGH_MS
Milliseconds of delay after get() where set() storms are a consideration with 'lockTSE'.
reap( $key, $purgeTimestamp, &$isStale=false)
Set a key to soon expire in the local cluster if it pre-dates $purgeTimestamp.
makePurgeValue( $timestamp, $holdoff)
getRawKeysForWarmup(array $keys, array $checkKeys)
const RECENT_SET_LOW_MS
Min millisecond set() backoff for keys in hold-off (far less than INTERIM_KEY_TTL)
setLogger(LoggerInterface $logger)
reapCheckKey( $key, $purgeTimestamp, &$isStale=false)
Set a "check" key to soon expire in the local cluster if it pre-dates $purgeTimestamp.
const PASS_BY_REF
Parameter to get()/getMulti() to return extra information by reference.
makeKey( $class, $component=null)
clearLastError()
Clear the "last error" registry.
const STALE_TTL_NONE
Idiom for set()/getWithSetCallback() for "do not augment the storage medium TTL".
MapCacheLRU[] $processCaches
Map of group PHP instance caches.
const TSE_NONE
Idiom for getWithSetCallback() callbacks to 'lockTSE' logic.
resetCheckKey( $key)
Delete a "check" key from all datacenters, invalidating keys that use it.
makeGlobalKey( $class, $component=null)
const MAX_COMMIT_DELAY
Max time expected to pass between delete() and DB commit finishing.
const AGE_NEW
Never consider performing "popularity" refreshes until a key reaches this age.
const RAMPUP_TTL
Seconds to ramp up to the "popularity" refresh chance after a key is no longer new.
const TTL_LAGGED
Max TTL to store keys when a data sourced is lagged.
isAliveOrInGracePeriod( $curTTL, $graceTTL)
Check if a key is fresh or in the grace window and thus due for randomized reuse.
getMultiCheckKeyTime(array $keys)
Fetch the values of each timestamp "check" key.
$mcrouterAware
@bar bool Whether to use mcrouter key prefixing for routing
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
see documentation in includes Linker php for Linker::makeImageLink & $time
namespace being checked & $result
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
processing should stop and the error should be shown to the user * false
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Generic interface for lightweight expiring object stores.
you have access to all of the normal MediaWiki so you can get a DB use the cache
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))