MediaWiki REL1_33
NearExpiringWANObjectCache Class Reference
Inheritance diagram for NearExpiringWANObjectCache:
Collaboration diagram for NearExpiringWANObjectCache:

Public Attributes

const CLOCK_SKEW = 1
 
- Public Attributes inherited from WANObjectCache
const AGE_NEW = 60
 Never consider performing "popularity" refreshes until a key reaches this age.
 
const CHECK_KEY_TTL = self::TTL_YEAR
 Seconds to keep dependency purge keys around.
 
const COOLOFF_KEY_PREFIX = 'WANCache:c:'
 
const COOLOFF_TTL = 1
 Seconds to no-op key set() calls to avoid large blob I/O stampedes.
 
const FLD_FLAGS = 4
 
const FLD_HOLDOFF = 5
 
const FLD_TIME = 3
 
const FLD_TTL = 2
 
const FLD_VALUE = 1
 
const FLD_VERSION = 0
 
const GRACE_TTL_NONE = 0
 Idiom for set()/getWithSetCallback() for "no post-expired grace period".
 
const HIT_RATE_HIGH = 1
 Hits/second for a refresh to be expected within the "popularity" window.
 
const HOLDOFF_NONE = 0
 Idiom for delete() for "no hold-off".
 
const HOLDOFF_TTL = 11
 Seconds to tombstone keys on delete()
 
const HOT_TTR = 900
 The time length of the "popularity" refresh window for hot keys.
 
const INTERIM_KEY_PREFIX = 'WANCache:i:'
 
const INTERIM_KEY_TTL = 1
 Seconds to keep interim value keys for tombstoned keys around.
 
const LOCK_TTL = 10
 Seconds to keep lock keys around.
 
const LOW_TTL = 30
 Default remaining TTL at which to consider pre-emptive regeneration.
 
const MAX_COMMIT_DELAY = 3
 Max time expected to pass between delete() and DB commit finishing.
 
const MAX_READ_LAG = 7
 Max replication+snapshot lag before applying TTL_LAGGED or disallowing set()
 
const MIN_TIMESTAMP_NONE = 0.0
 Idiom for getWithSetCallback() for "no minimum required as-of timestamp".
 
const MUTEX_KEY_PREFIX = 'WANCache:m:'
 
const PASS_BY_REF = -1
 Parameter to get()/getMulti() to return extra information by reference.
 
const PC_PRIMARY = 'primary:1000'
 
const PURGE_VAL_PREFIX = 'PURGED:'
 
const RAMPUP_TTL = 30
 Seconds to ramp up to the "popularity" refresh chance after a key is no longer new.
 
const RECENT_SET_HIGH_MS = 100
 Max millisecond set() backoff for keys in hold-off (far less than INTERIM_KEY_TTL)
 
const RECENT_SET_LOW_MS = 50
 Min millisecond set() backoff for keys in hold-off (far less than INTERIM_KEY_TTL)
 
const SET_DELAY_HIGH_MS = 50
 Milliseconds of delay after get() where set() storms are a consideration with 'lockTSE'.
 
const STALE_TTL_NONE = 0
 Idiom for set()/getWithSetCallback() for "do not augment the storage medium TTL".
 
const TIME_KEY_PREFIX = 'WANCache:t:'
 
const TINY_NEGATIVE = -0.000001
 Tiny negative float to use when CTL comes up >= 0 due to clock skew.
 
const TINY_POSTIVE = 0.000001
 Tiny positive float to use when using "minTime" to assert an inequality.
 
const TSE_NONE = -1
 Idiom for getWithSetCallback() callbacks to 'lockTSE' logic.
 
const TTL_LAGGED = 30
 Max TTL to store keys when a data sourced is lagged.
 
const TTL_UNCACHEABLE = -1
 Idiom for getWithSetCallback() callbacks to avoid calling set()
 
const VALUE_KEY_PREFIX = 'WANCache:v:'
 
const VERSION = 1
 Cache format version number.
 
const VFLD_DATA = 'WOC:d'
 
const VFLD_VERSION = 'WOC:v'
 
- Public Attributes inherited from IExpiringStore
const ATTR_EMULATION = 1
 
const ATTR_SYNCWRITES = 2
 
const ERR_NO_RESPONSE = 1
 
const ERR_NONE = 0
 
const ERR_UNEXPECTED = 3
 
const ERR_UNREACHABLE = 2
 
const QOS_EMULATION_SQL = 1
 
const QOS_SYNCWRITES_BE = 2
 
const QOS_SYNCWRITES_NONE = 1
 
const QOS_SYNCWRITES_QC = 3
 
const QOS_SYNCWRITES_SS = 4
 
const QOS_UNKNOWN = INF
 
const TTL_DAY = 86400
 
const TTL_HOUR = 3600
 
const TTL_INDEFINITE = 0
 
const TTL_MINUTE = 60
 
const TTL_MONTH = 2592000
 
const TTL_PROC_LONG = 30
 
const TTL_PROC_SHORT = 3
 
const TTL_SECOND = 1
 
const TTL_WEEK = 604800
 
const TTL_YEAR = 31536000
 

Protected Member Functions

 worthRefreshExpiring ( $curTTL, $lowTTL)
 Check if a key is nearing expiration and thus due for randomized regeneration.
 
- Protected Member Functions inherited from WANObjectCache
 determineKeyClassForStats ( $key)
 
 doGetWithSetCallback ( $key, $ttl, $callback, array $opts, &$asOf=null)
 Do the actual I/O for getWithSetCallback() when needed.
 
 getCurrentTime ()
 
 getInterimValue ( $key, $versioned, $minTime)
 
 getProcessCache ( $group)
 
 isAliveOrInGracePeriod ( $curTTL, $graceTTL)
 Check if a key is fresh or in the grace window and thus due for randomized reuse.
 
 isValid ( $value, $versioned, $asOf, $minTime, $purgeTime=null)
 Check if $value is not false, versioned (if needed), and not older than $minTime (if set)
 
 makePurgeValue ( $timestamp, $holdoff)
 
 parsePurgeValue ( $value)
 
 relayDelete ( $key)
 Do the actual async bus delete of a key.
 
 relayPurge ( $key, $ttl, $holdoff)
 Do the actual async bus purge of a key.
 
 resolveCTL ( $value, $curTTL, $curInfo, $touchedCallback)
 
 resolveTouched ( $value, $lastPurge, $touchedCallback)
 
 setInterimValue ( $key, $value, $tempTTL, $newAsOf)
 
 unwrap ( $wrapped, $now)
 Do not use this method outside WANObjectCache.
 
 worthRefreshPopular ( $asOf, $ageNew, $timeTillRefresh, $now)
 Check if a key is due for randomized regeneration due to its popularity.
 
 wrap ( $value, $ttl, $now)
 Do not use this method outside WANObjectCache.
 

Additional Inherited Members

- Public Member Functions inherited from WANObjectCache
 __construct (array $params)
 
 adaptiveTTL ( $mtime, $maxTTL, $minTTL=30, $factor=0.2)
 Get a TTL that is higher for objects that have not changed recently.
 
 clearLastError ()
 Clear the "last error" registry.
 
 clearProcessCache ()
 Clear the in-process caches; useful for testing.
 
 delete ( $key, $ttl=self::HOLDOFF_TTL)
 Purge a key from all datacenters.
 
 get ( $key, &$curTTL=null, array $checkKeys=[], &$info=null)
 Fetch the value of a key from cache.
 
 getCheckKeyTime ( $key)
 Fetch the value of a timestamp "check" key.
 
 getLastError ()
 Get the "last error" registered; clearLastError() should be called manually.
 
 getMulti (array $keys, &$curTTLs=[], array $checkKeys=[], &$info=null)
 Fetch the value of several keys from cache.
 
 getMultiCheckKeyTime (array $keys)
 Fetch the values of each timestamp "check" key.
 
 getMultiWithSetCallback (ArrayIterator $keyedIds, $ttl, callable $callback, array $opts=[])
 Method to fetch multiple cache keys at once with regeneration.
 
 getMultiWithUnionSetCallback (ArrayIterator $keyedIds, $ttl, callable $callback, array $opts=[])
 Method to fetch/regenerate multiple cache keys at once.
 
 getQoS ( $flag)
 
 getWarmupKeyMisses ()
 
 getWithSetCallback ( $key, $ttl, $callback, array $opts=[])
 Method to fetch/regenerate cache keys.
 
 makeGlobalKey ( $class, $component=null)
 
 makeKey ( $class, $component=null)
 
 makeMultiKeys (array $entities, callable $keyFunc)
 
 reap ( $key, $purgeTimestamp, &$isStale=false)
 Set a key to soon expire in the local cluster if it pre-dates $purgeTimestamp.
 
 reapCheckKey ( $key, $purgeTimestamp, &$isStale=false)
 Set a "check" key to soon expire in the local cluster if it pre-dates $purgeTimestamp.
 
 resetCheckKey ( $key)
 Delete a "check" key from all datacenters, invalidating keys that use it.
 
 set ( $key, $value, $ttl=self::TTL_INDEFINITE, array $opts=[])
 Set the value of a key in cache.
 
 setLogger (LoggerInterface $logger)
 
 setMockTime (&$time)
 
 touchCheckKey ( $key, $holdoff=self::HOLDOFF_TTL)
 Purge a "check" key from all datacenters, invalidating keys that use it.
 
 useInterimHoldOffCaching ( $enabled)
 Enable or disable the use of brief caching for tombstoned keys.
 
- Static Public Member Functions inherited from WANObjectCache
static newEmpty ()
 Get an instance that wraps EmptyBagOStuff.
 
- Static Protected Member Functions inherited from WANObjectCache
static prefixCacheKeys (array $keys, $prefix)
 
- Protected Attributes inherited from WANObjectCache
callable null $asyncHandler
 Function that takes a WAN cache callback and runs it later.
 
BagOStuff $cache
 The local datacenter cache.
 
string $cluster
 Cache cluster name for mcrouter use.
 
float $epoch
 Unix timestamp of the oldest possible valid values.
 
LoggerInterface $logger
 
 $mcrouterAware
 @bar bool Whether to use mcrouter key prefixing for routing
 
MapCacheLRU[] $processCaches = []
 Map of group PHP instance caches.
 
string $region
 Physical region for mcrouter use.
 
StatsdDataFactoryInterface $stats
 
bool $useInterimHoldOffCaching = true
 Whether to use "interim" caching while keys are tombstoned.
 

Detailed Description

Definition at line 1855 of file WANObjectCacheTest.php.

Member Function Documentation

◆ worthRefreshExpiring()

NearExpiringWANObjectCache::worthRefreshExpiring (   $curTTL,
  $lowTTL 
)
protected

Check if a key is nearing expiration and thus due for randomized regeneration.

This returns false if $curTTL >= $lowTTL. Otherwise, the chance of returning true increases steadily from 0% to 100% as the $curTTL moves from $lowTTL to 0 seconds. This handles widely varying levels of cache access traffic.

If $curTTL <= 0 (e.g. already expired), then this returns false.

Parameters
float$curTTLApproximate TTL left on the key if present
float$lowTTLConsider a refresh when $curTTL is less than this
Returns
bool

Reimplemented from WANObjectCache.

Definition at line 1858 of file WANObjectCacheTest.php.

Member Data Documentation

◆ CLOCK_SKEW

const NearExpiringWANObjectCache::CLOCK_SKEW = 1

Definition at line 1856 of file WANObjectCacheTest.php.


The documentation for this class was generated from the following file: