MediaWiki  1.33.0
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. More...
 
const CHECK_KEY_TTL = self::TTL_YEAR
 Seconds to keep dependency purge keys around. More...
 
const COOLOFF_KEY_PREFIX = 'WANCache:c:'
 
const COOLOFF_TTL = 1
 Seconds to no-op key set() calls to avoid large blob I/O stampedes. More...
 
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". More...
 
const HIT_RATE_HIGH = 1
 Hits/second for a refresh to be expected within the "popularity" window. More...
 
const HOLDOFF_NONE = 0
 Idiom for delete() for "no hold-off". More...
 
const HOLDOFF_TTL = 11
 Seconds to tombstone keys on delete() More...
 
const HOT_TTR = 900
 The time length of the "popularity" refresh window for hot keys. More...
 
const INTERIM_KEY_PREFIX = 'WANCache:i:'
 
const INTERIM_KEY_TTL = 1
 Seconds to keep interim value keys for tombstoned keys around. More...
 
const LOCK_TTL = 10
 Seconds to keep lock keys around. More...
 
const LOW_TTL = 30
 Default remaining TTL at which to consider pre-emptive regeneration. More...
 
const MAX_COMMIT_DELAY = 3
 Max time expected to pass between delete() and DB commit finishing. More...
 
const MAX_READ_LAG = 7
 Max replication+snapshot lag before applying TTL_LAGGED or disallowing set() More...
 
const MIN_TIMESTAMP_NONE = 0.0
 Idiom for getWithSetCallback() for "no minimum required as-of timestamp". More...
 
const MUTEX_KEY_PREFIX = 'WANCache:m:'
 
const PASS_BY_REF = -1
 Parameter to get()/getMulti() to return extra information by reference. More...
 
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. More...
 
const RECENT_SET_HIGH_MS = 100
 Max millisecond set() backoff for keys in hold-off (far less than INTERIM_KEY_TTL) More...
 
const RECENT_SET_LOW_MS = 50
 Min millisecond set() backoff for keys in hold-off (far less than INTERIM_KEY_TTL) More...
 
const SET_DELAY_HIGH_MS = 50
 Milliseconds of delay after get() where set() storms are a consideration with 'lockTSE'. More...
 
const STALE_TTL_NONE = 0
 Idiom for set()/getWithSetCallback() for "do not augment the storage medium TTL". More...
 
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. More...
 
const TINY_POSTIVE = 0.000001
 Tiny positive float to use when using "minTime" to assert an inequality. More...
 
const TSE_NONE = -1
 Idiom for getWithSetCallback() callbacks to 'lockTSE' logic. More...
 
const TTL_LAGGED = 30
 Max TTL to store keys when a data sourced is lagged. More...
 
const TTL_UNCACHEABLE = -1
 Idiom for getWithSetCallback() callbacks to avoid calling set() More...
 
const VALUE_KEY_PREFIX = 'WANCache:v:'
 
const VERSION = 1
 Cache format version number. More...
 
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. More...
 
- 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. More...
 
 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. More...
 
 isValid ( $value, $versioned, $asOf, $minTime, $purgeTime=null)
 Check if $value is not false, versioned (if needed), and not older than $minTime (if set) More...
 
 makePurgeValue ( $timestamp, $holdoff)
 
 parsePurgeValue ( $value)
 
 relayDelete ( $key)
 Do the actual async bus delete of a key. More...
 
 relayPurge ( $key, $ttl, $holdoff)
 Do the actual async bus purge of a key. More...
 
 resolveCTL ( $value, $curTTL, $curInfo, $touchedCallback)
 
 resolveTouched ( $value, $lastPurge, $touchedCallback)
 
 setInterimValue ( $key, $value, $tempTTL, $newAsOf)
 
 unwrap ( $wrapped, $now)
 Do not use this method outside WANObjectCache. More...
 
 worthRefreshPopular ( $asOf, $ageNew, $timeTillRefresh, $now)
 Check if a key is due for randomized regeneration due to its popularity. More...
 
 wrap ( $value, $ttl, $now)
 Do not use this method outside WANObjectCache. More...
 

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. More...
 
 clearLastError ()
 Clear the "last error" registry. More...
 
 clearProcessCache ()
 Clear the in-process caches; useful for testing. More...
 
 delete ( $key, $ttl=self::HOLDOFF_TTL)
 Purge a key from all datacenters. More...
 
 get ( $key, &$curTTL=null, array $checkKeys=[], &$info=null)
 Fetch the value of a key from cache. More...
 
 getCheckKeyTime ( $key)
 Fetch the value of a timestamp "check" key. More...
 
 getLastError ()
 Get the "last error" registered; clearLastError() should be called manually. More...
 
 getMulti (array $keys, &$curTTLs=[], array $checkKeys=[], &$info=null)
 Fetch the value of several keys from cache. More...
 
 getMultiCheckKeyTime (array $keys)
 Fetch the values of each timestamp "check" key. More...
 
 getMultiWithSetCallback (ArrayIterator $keyedIds, $ttl, callable $callback, array $opts=[])
 Method to fetch multiple cache keys at once with regeneration. More...
 
 getMultiWithUnionSetCallback (ArrayIterator $keyedIds, $ttl, callable $callback, array $opts=[])
 Method to fetch/regenerate multiple cache keys at once. More...
 
 getQoS ( $flag)
 
 getWarmupKeyMisses ()
 
 getWithSetCallback ( $key, $ttl, $callback, array $opts=[])
 Method to fetch/regenerate cache keys. More...
 
 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. More...
 
 reapCheckKey ( $key, $purgeTimestamp, &$isStale=false)
 Set a "check" key to soon expire in the local cluster if it pre-dates $purgeTimestamp. More...
 
 resetCheckKey ( $key)
 Delete a "check" key from all datacenters, invalidating keys that use it. More...
 
 set ( $key, $value, $ttl=self::TTL_INDEFINITE, array $opts=[])
 Set the value of a key in cache. More...
 
 setLogger (LoggerInterface $logger)
 
 setMockTime (&$time)
 
 touchCheckKey ( $key, $holdoff=self::HOLDOFF_TTL)
 Purge a "check" key from all datacenters, invalidating keys that use it. More...
 
 useInterimHoldOffCaching ( $enabled)
 Enable or disable the use of brief caching for tombstoned keys. More...
 
- Static Public Member Functions inherited from WANObjectCache
static newEmpty ()
 Get an instance that wraps EmptyBagOStuff. More...
 
- 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. More...
 
BagOStuff $cache
 The local datacenter cache. More...
 
string $cluster
 Cache cluster name for mcrouter use. More...
 
float $epoch
 Unix timestamp of the oldest possible valid values. More...
 
LoggerInterface $logger
 
 $mcrouterAware
 @bar bool Whether to use mcrouter key prefixing for routing More...
 
MapCacheLRU[] $processCaches = []
 Map of group PHP instance caches. More...
 
string $region
 Physical region for mcrouter use. More...
 
StatsdDataFactoryInterface $stats
 
bool $useInterimHoldOffCaching = true
 Whether to use "interim" caching while keys are tombstoned. More...
 

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: