MediaWiki
1.28.0
|
Multi-datacenter aware caching interface. More...
Public Member Functions | |
__construct (array $params) | |
adaptiveTTL ($mtime, $maxTTL, $minTTL=30, $factor=.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=[], &$asOf=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=[], array &$asOfs=[]) | |
Fetch the value of several keys from cache. More... | |
getMultiWithSetCallback (ArrayIterator $keyedIds, $ttl, callable $callback, array $opts=[]) | |
Method to fetch/regenerate multiple cache keys at once. More... | |
getQoS ($flag) | |
getWithSetCallback ($key, $ttl, $callback, array $opts=[]) | |
Method to fetch/regenerate cache keys. More... | |
makeGlobalKey () | |
makeKey () | |
makeMultiKeys (array $entities, callable $keyFunc) | |
resetCheckKey ($key) | |
Delete a "check" key from all datacenters, invalidating keys that use it. More... | |
set ($key, $value, $ttl=0, array $opts=[]) | |
Set the value of a key in cache. More... | |
setLogger (LoggerInterface $logger) | |
touchCheckKey ($key, $holdoff=self::HOLDOFF_TTL) | |
Purge a "check" key from all datacenters, invalidating keys that use it. More... | |
Static Public Member Functions | |
static | newEmpty () |
Get an instance that wraps EmptyBagOStuff. More... | |
Public Attributes | |
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 | DEFAULT_PURGE_CHANNEL = 'wancache-purge' |
const | ERR_NO_RESPONSE = 1 |
const | ERR_NONE = 0 |
const | ERR_RELAY = 4 |
const | ERR_UNEXPECTED = 3 |
const | ERR_UNREACHABLE = 2 |
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 | 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 | LOCK_TSE = 1 |
Default time-since-expiry on a miss that makes a key "hot". 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 | 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 | 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 | 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 | 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_WEEK = 604800 |
const | TTL_YEAR = 31536000 |
Protected Member Functions | |
doGetWithSetCallback ($key, $ttl, $callback, array $opts, &$asOf=null) | |
Do the actual I/O for getWithSetCallback() when needed. More... | |
getProcessCache ($group) | |
isValid ($value, $versioned, $asOf, $minTime) | |
Check whether $value is appropriately versioned and not older than $minTime (if set) More... | |
makePurgeValue ($timestamp, $holdoff) | |
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... | |
unwrap ($wrapped, $now) | |
Do not use this method outside WANObjectCache. More... | |
worthRefreshExpiring ($curTTL, $lowTTL) | |
Check if a key should be regenerated (using random probability) 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... | |
Static Protected Member Functions | |
static | parsePurgeValue ($value) |
static | prefixCacheKeys (array $keys, $prefix) |
Protected Attributes | |
BagOStuff | $cache |
The local datacenter cache. More... | |
int | $lastRelayError = self::ERR_NONE |
ERR_* constant for the "last error" registry. More... | |
LoggerInterface | $logger |
HashBagOStuff[] | $processCaches = [] |
Map of group PHP instance caches. More... | |
string | $purgeChannel |
Purge channel name. More... | |
EventRelayer | $purgeRelayer |
Bus that handles purge broadcasts. More... | |
Private Member Functions | |
processCheckKeys (array $timeKeys, array $wrappedValues, $now) | |
Private Attributes | |
integer | $callbackDepth = 0 |
Callback stack depth for getWithSetCallback() More... | |
mixed[] | $warmupCache = [] |
Temporary warm-up cache. More... | |
Multi-datacenter aware caching interface.
All operations go to the local datacenter cache, except for delete(), touchCheckKey(), and resetCheckKey(), which broadcast to all datacenters.
This class is intended for caching data from primary stores. If the get() method does not return a value, then the caller should query the new value and backfill the cache using set(). The preferred way to do this logic is through getWithSetCallback(). When querying the store on cache miss, the closest DB replica should be used. Try to avoid heavyweight DB master or quorum reads. When the source data changes, a purge method should be called. Since purges are expensive, they should be avoided. One can do so if:
The simplest purge method is delete().
There are two supported ways to handle broadcasted operations:
Broadcasted operations like delete() and touchCheckKey() are done asynchronously in all datacenters this way, though the local one should likely be near immediate.
This means that callers in all datacenters may see older values for however many milliseconds that the purge took to reach that datacenter. As with any cache, this should not be relied on for cases where reads are used to determine writes to source (e.g. non-cache) data stores, except when reading immutable data.
All values are wrapped in metadata arrays. Keys use a "WANCache:" prefix to avoid collisions with keys that are not wrapped as metadata arrays. The prefixes are as follows:
Definition at line 76 of file WANObjectCache.php.
WANObjectCache::__construct | ( | array | $params | ) |
array | $params |
|
Definition at line 175 of file WANObjectCache.php.
References cache, and setLogger().
WANObjectCache::adaptiveTTL | ( | $mtime, | |
$maxTTL, | |||
$minTTL = 30 , |
|||
$factor = .2 |
|||
) |
Get a TTL that is higher for objects that have not changed recently.
This is useful for keys that get explicit purges and DB or purge relay lag is a potential concern (especially how it interacts with CDN cache)
Example usage:
integer | float | $mtime | UNIX timestamp |
integer | $maxTTL | Maximum TTL (seconds) |
integer | $minTTL | Minimum TTL (seconds); Default: 30 |
float | $factor | Value in the range (0,1); Default: .2 |
Definition at line 1241 of file WANObjectCache.php.
|
final |
Clear the "last error" registry.
Definition at line 1195 of file WANObjectCache.php.
References cache.
WANObjectCache::clearProcessCache | ( | ) |
Clear the in-process caches; useful for testing.
Definition at line 1205 of file WANObjectCache.php.
|
final |
Purge a key from all datacenters.
This should only be called when the underlying data (being cached) changes in a significant way. This deletes the key and starts a hold-off period where the key cannot be written to for a few seconds (HOLDOFF_TTL). This is done to avoid the following race condition:
This is implemented by storing a special "tombstone" value at the cache key that this class recognizes; get() calls will return false for the key and any set() calls will refuse to replace tombstone values at the key. For this to always avoid stale value writes, the following must hold:
Note that set() can also be lag-aware and lower the TTL if it's high.
When using potentially long-running ACID transactions, a good pattern is to use a pre-commit hook to issue the delete. This means that immediately after commit, callers will see the tombstone in cache upon purge relay. It also avoids the following race condition:
Example usage:
The $ttl parameter can be used when purging values that have not actually changed recently. For example, a cleanup script to purge cache entries does not really need a hold-off period, so it can use HOLDOFF_NONE. Likewise for user-requested purge. Note that $ttl limits the effective range of 'lockTSE' for getWithSetCallback().
If called twice on the same key, then the last hold-off TTL takes precedence. For idempotence, the $ttl should not vary for different delete() calls on the same key.
string | $key | Cache key |
integer | $ttl | Tombstone TTL; Default: WANObjectCache::HOLDOFF_TTL |
Definition at line 535 of file WANObjectCache.php.
References relayDelete(), and relayPurge().
Referenced by WANObjectCacheTest\testBusyValue(), WANObjectCacheTest\testGetMultiWithSetCallback(), WANObjectCacheTest\testGetWithSetCallback(), WANObjectCacheTest\testGetWithSetCallback_versions(), WANObjectCacheTest\testLockTSE(), and WANObjectCacheTest\testLockTSESlow().
|
protected |
Do the actual I/O for getWithSetCallback() when needed.
string | $key | |
integer | $ttl | |
callback | $callback | |
array | $opts | Options map for getWithSetCallback() |
float | &$asOf | Cache generation timestamp of returned value [returned] |
Definition at line 931 of file WANObjectCache.php.
References $callbackDepth, $value, cache, false, isValid(), list, set(), unwrap(), use, worthRefreshExpiring(), worthRefreshPopular(), and wrap().
Referenced by getWithSetCallback().
|
final |
Fetch the value of a key from cache.
If supplied, $curTTL is set to the remaining TTL (current time left):
If a key is tombstoned, $curTTL will reflect the time since delete().
The timestamp of $key will be checked against the last-purge timestamp of each of $checkKeys. Those $checkKeys not in cache will have the last-purge initialized to the current timestamp. If any of $checkKeys have a timestamp greater than that of $key, then $curTTL will reflect how long ago $key became invalid. Callers can use $curTTL to know when the value is stale. The $checkKeys parameter allow mass invalidations by updating a single key:
Source data entities might exists in a DB that uses snapshot isolation (e.g. the default REPEATABLE-READ in innoDB). Even for mutable data, that isolation can largely be maintained by doing the following:
However, pre-snapshot values might still be seen if an update was made in a remote datacenter but the purge from delete() didn't relay yet.
Consider using getWithSetCallback() instead of get() and set() cycles. That method has cache slam avoiding features for hot/expensive keys.
string | $key | Cache key |
mixed | $curTTL | Approximate TTL left on the key if present/tombstoned [returned] |
array | $checkKeys | List of "check" keys |
float | &$asOf | UNIX timestamp of cached value; null on failure [returned] |
Definition at line 243 of file WANObjectCache.php.
References getMulti().
Referenced by JobQueueDB\doDeduplicateRootJob(), WANObjectCacheTest\testCheckKeyInitHoldoff(), WANObjectCacheTest\testGetMultiWithSetCallback(), WANObjectCacheTest\testGetWithSetCallback(), and WANObjectCacheTest\testLockTSESlow().
|
final |
Fetch the value of a timestamp "check" key.
The key will be initialized to the current time if not set, so only call this method if this behavior is actually desired
The timestamp can be used to check whether a cached value is valid. Callers should not assume that this returns the same timestamp in all datacenters due to relay delays.
The level of staleness can roughly be estimated from this key, but if the key was evicted from cache, such calculations may show the time since expiry as ~0 seconds.
Note that "check" keys won't collide with other regular keys.
string | $key |
Definition at line 568 of file WANObjectCache.php.
References $time, cache, makePurgeValue(), and string.
Referenced by WANObjectCacheTest\testGetMulti(), WANObjectCacheTest\testGetMultiWithSetCallback(), and WANObjectCacheTest\testGetWithSetCallback().
|
final |
Get the "last error" registered; clearLastError() should be called manually.
Definition at line 1169 of file WANObjectCache.php.
References $code, $lastRelayError, cache, BagOStuff\ERR_NO_RESPONSE, BagOStuff\ERR_NONE, and BagOStuff\ERR_UNREACHABLE.
|
final |
Fetch the value of several keys from cache.
array | $keys | List of cache keys |
array | $curTTLs | Map of (key => approximate TTL left) for existing keys [returned] |
array | $checkKeys | List of check keys to apply to all $keys. May also apply "check" keys to specific cache keys only by using cache keys as keys in the $checkKeys array. |
float[] | &$asOfs Map of (key => UNIX timestamp of cached value; null on failure) |
Definition at line 265 of file WANObjectCache.php.
References $value, array(), as, cache, false, list, processCheckKeys(), and unwrap().
Referenced by get(), WANObjectCacheTest\testGetMulti(), and WANObjectCacheTest\testGetMultiCheckKeys().
|
final |
Method to fetch/regenerate multiple cache keys at once.
This works the same as getWithSetCallback() except:
Example usage:
ArrayIterator | $keyedIds | Result of WANObjectCache::makeMultiKeys() |
integer | $ttl | Seconds to live for key updates |
callable | $callback | Callback the yields entity regeneration callbacks |
array | $opts | Options map |
Definition at line 1098 of file WANObjectCache.php.
References array(), as, cache, getWithSetCallback(), and use.
Referenced by WANObjectCacheTest\testGetMultiWithSetCallback().
|
protected |
string | $group |
Definition at line 1502 of file WANObjectCache.php.
References list.
Referenced by getWithSetCallback().
WANObjectCache::getQoS | ( | $flag | ) |
integer | $flag | ATTR_* class constant |
Definition at line 1214 of file WANObjectCache.php.
References cache.
|
final |
Method to fetch/regenerate cache keys.
On cache miss, the key will be set to the callback result via set() (unless the callback returns false) and that result will be returned. The arguments supplied to the callback are:
It is strongly recommended to set the 'lag' and 'since' fields to avoid race conditions that can cause stale values to get stuck at keys. Usually, callbacks ignore the current value, but it can be used to maintain "most recent X" values that come from time or sequence based source data, provided that the "as of" id/time is tracked. Note that preemptive regeneration and $checkKeys can result in a non-false current value.
Usage of $checkKeys is similar to get() and getMulti(). However, rather than the caller having to inspect a "current time left" variable (e.g. $curTTL, $curTTLs), a cache regeneration will automatically be triggered using the callback.
The simplest way to avoid stampedes for hot keys is to use the 'lockTSE' option in $opts. If cache purges are needed, also:
Example usage (typical key):
Example usage (key that is expensive and hot):
Example usage (key with dynamic dependencies):
Example usage (hot key holding most recent 100 events):
string | $key | Cache key |
integer | $ttl | Seconds to live for key updates. Special values are:
|
callable | $callback | Value generation function |
array | $opts | Options map:
|
Definition at line 849 of file WANObjectCache.php.
References $value, doGetWithSetCallback(), getProcessCache(), and use.
Referenced by getMultiWithSetCallback(), WANObjectCacheTest\testBusyValue(), WANObjectCacheTest\testGetWithSetCallback(), WANObjectCacheTest\testGetWithSetCallback_versions(), WANObjectCacheTest\testLockTSE(), and WANObjectCacheTest\testLockTSESlow().
|
protected |
Check whether $value is appropriately versioned and not older than $minTime (if set)
array | $value | |
bool | $versioned | |
float | $asOf | The time $value was generated |
float | $minTime | The last time the main value was generated (0.0 if unknown) |
Definition at line 1383 of file WANObjectCache.php.
References $value.
Referenced by doGetWithSetCallback().
WANObjectCache::makeGlobalKey | ( | ) |
string | ... Key component |
Definition at line 1146 of file WANObjectCache.php.
References cache.
Referenced by User\getCacheKey().
WANObjectCache::makeKey | ( | ) |
string | ... Key component |
Definition at line 1136 of file WANObjectCache.php.
References cache.
WANObjectCache::makeMultiKeys | ( | array | $entities, |
callable | $keyFunc | ||
) |
array | $entities | List of entity IDs |
callable | $keyFunc | Callback yielding a key from (entity ID, this WANObjectCache) |
Definition at line 1156 of file WANObjectCache.php.
References as.
Referenced by WANObjectCacheTest\testGetMultiWithSetCallback().
|
protected |
float | $timestamp | |
int | $holdoff | In seconds |
Definition at line 1494 of file WANObjectCache.php.
References $timestamp.
Referenced by getCheckKeyTime(), processCheckKeys(), and relayPurge().
|
static |
Get an instance that wraps EmptyBagOStuff.
Definition at line 195 of file WANObjectCache.php.
Referenced by FileBackendStore\__construct(), LBFactory\__construct(), LoadBalancer\__construct(), ClassicInterwikiLookupTest\testArrayStorage(), ClassicInterwikiLookupTest\testCDBStorage(), and ClassicInterwikiLookupTest\testDatabaseStorage().
|
staticprotected |
string | $value | Wrapped value like "PURGED:<timestamp>:<holdoff>" |
Definition at line 1469 of file WANObjectCache.php.
References $value.
|
staticprotected |
array | $keys | |
string | $prefix |
Definition at line 1455 of file WANObjectCache.php.
array | $timeKeys | List of prefixed time check keys |
array | $wrappedValues | |
float | $now |
Definition at line 353 of file WANObjectCache.php.
References as, cache, and makePurgeValue().
Referenced by getMulti().
|
protected |
Do the actual async bus delete of a key.
string | $key | Cache key |
Definition at line 1296 of file WANObjectCache.php.
References cache.
Referenced by delete(), and resetCheckKey().
|
protected |
Do the actual async bus purge of a key.
This must set the key to "PURGED:<UNIX timestamp>:<holdoff>"
string | $key | Cache key |
integer | $ttl | How long to keep the tombstone [seconds] |
integer | $holdoff | HOLDOFF_* constant controlling how long to ignore sets for this key |
Definition at line 1265 of file WANObjectCache.php.
References cache, and makePurgeValue().
Referenced by delete(), and touchCheckKey().
|
final |
Delete a "check" key from all datacenters, invalidating keys that use it.
This is similar to touchCheckKey() in that keys using it via get(), getMulti(), or getWithSetCallback() will be invalidated. The differences are:
The advantage is that this does not place high TTL keys on every cache server, making it better for code that will cache many different keys and either does not use lockTSE or uses a low enough TTL anyway.
This is typically useful for keys with dynamically generated names where a high number of combinations exist.
Note that "check" keys won't collide with other regular keys.
string | $key | Cache key |
Definition at line 655 of file WANObjectCache.php.
References relayDelete().
|
final |
Set the value of a key in cache.
Simply calling this method when source data changes is not valid because the changes do not replicate to the other WAN sites. In that case, delete() should be used instead. This method is intended for use on cache misses.
If the data was read from a snapshot-isolated transactions (e.g. the default REPEATABLE-READ in innoDB), use 'since' to avoid the following race condition:
Setting 'lag' and 'since' help avoids keys getting stuck in stale states.
Example usage:
string | $key | Cache key |
mixed | $value | |
integer | $ttl | Seconds to live. Special values are:
|
array | $opts | Options map:
|
Definition at line 428 of file WANObjectCache.php.
References $cache, $value, cache, use, and wrap().
Referenced by JobQueueDB\doDeduplicateRootJob(), doGetWithSetCallback(), WANObjectCacheTest\testCheckKeyInitHoldoff(), WANObjectCacheTest\testGetMulti(), and WANObjectCacheTest\testGetMultiCheckKeys().
WANObjectCache::setLogger | ( | LoggerInterface | $logger | ) |
|
final |
Purge a "check" key from all datacenters, invalidating keys that use it.
This should only be called when the underlying data (being cached) changes in a significant way, and it is impractical to call delete() on all keys that should be changed. When get() is called on those keys, the relevant "check" keys must be supplied for this to work.
The "check" key essentially represents a last-modified field. When touched, the field will be updated on all cache servers. Keys using it via get(), getMulti(), or getWithSetCallback() will be invalidated. It is treated as being HOLDOFF_TTL seconds in the future by those methods to avoid race conditions where dependent keys get updated with stale values (e.g. from a DB replica DB).
This is typically useful for keys with hardcoded names or in some cases dynamically generated names where a low number of combinations exist. When a few important keys get a large number of hits, a high cache time is usually desired as well as "lockTSE" logic. The resetCheckKey() method is less appropriate in such cases since the "time since expiry" cannot be inferred, causing any get() after the reset to treat the key as being "hot", resulting in more stale value usage.
Note that "check" keys won't collide with other regular keys.
string | $key | Cache key |
int | $holdoff | HOLDOFF_TTL or HOLDOFF_NONE constant |
Definition at line 620 of file WANObjectCache.php.
References relayPurge().
Referenced by WANObjectCacheTest\testGetMultiCheckKeys().
|
protected |
Do not use this method outside WANObjectCache.
array | string | bool | $wrapped | |
float | $now | Unix Current timestamp (preferrably pre-query) |
Definition at line 1417 of file WANObjectCache.php.
References $flags.
Referenced by doGetWithSetCallback(), and getMulti().
|
protected |
Check if a key should be regenerated (using random probability)
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.
float | $curTTL | Approximate TTL left on the key if present |
float | $lowTTL | Consider a refresh when $curTTL is less than this |
Definition at line 1327 of file WANObjectCache.php.
Referenced by doGetWithSetCallback().
|
protected |
Check if a key is due for randomized regeneration due to its popularity.
This is used so that popular keys can preemptively refresh themselves for higher consistency (especially in the case of purge loss/delay). Unpopular keys can remain in cache with their high nominal TTL. This means popular keys keep good consistency, whether the data changes frequently or not, and long-tail keys get to stay in cache and get hits too. Similar to worthRefreshExpiring(), randomization is used.
float | $asOf | UNIX timestamp of the value |
integer | $ageNew | Age of key when this might recommend refreshing (seconds) |
integer | $timeTillRefresh | Age of key when it should be refreshed if popular (seconds) |
float | $now | The current UNIX timestamp |
Definition at line 1354 of file WANObjectCache.php.
Referenced by doGetWithSetCallback().
|
protected |
Do not use this method outside WANObjectCache.
mixed | $value | |
integer | $ttl | [0=forever] |
float | $now | Unix Current timestamp just before calling set() |
Definition at line 1401 of file WANObjectCache.php.
References $value.
Referenced by doGetWithSetCallback(), and set().
|
protected |
|
private |
Callback stack depth for getWithSetCallback()
Definition at line 92 of file WANObjectCache.php.
Referenced by doGetWithSetCallback().
|
protected |
ERR_* constant for the "last error" registry.
Definition at line 89 of file WANObjectCache.php.
Referenced by getLastError().
|
protected |
Definition at line 86 of file WANObjectCache.php.
Referenced by setLogger().
|
protected |
Map of group PHP instance caches.
Definition at line 80 of file WANObjectCache.php.
|
protected |
Purge channel name.
Definition at line 82 of file WANObjectCache.php.
|
protected |
Bus that handles purge broadcasts.
Definition at line 84 of file WANObjectCache.php.
|
private |
Temporary warm-up cache.
Definition at line 94 of file WANObjectCache.php.
const WANObjectCache::AGE_NEW = 60 |
Never consider performing "popularity" refreshes until a key reaches this age.
Definition at line 113 of file WANObjectCache.php.
const WANObjectCache::CHECK_KEY_TTL = self::TTL_YEAR |
Seconds to keep dependency purge keys around.
Definition at line 104 of file WANObjectCache.php.
const WANObjectCache::DEFAULT_PURGE_CHANNEL = 'wancache-purge' |
Definition at line 166 of file WANObjectCache.php.
const WANObjectCache::ERR_NO_RESPONSE = 1 |
Definition at line 149 of file WANObjectCache.php.
const WANObjectCache::ERR_NONE = 0 |
Definition at line 148 of file WANObjectCache.php.
const WANObjectCache::ERR_RELAY = 4 |
Definition at line 152 of file WANObjectCache.php.
const WANObjectCache::ERR_UNEXPECTED = 3 |
Definition at line 151 of file WANObjectCache.php.
const WANObjectCache::ERR_UNREACHABLE = 2 |
Definition at line 150 of file WANObjectCache.php.
const WANObjectCache::FLD_FLAGS = 4 |
Definition at line 142 of file WANObjectCache.php.
const WANObjectCache::FLD_HOLDOFF = 5 |
Definition at line 143 of file WANObjectCache.php.
const WANObjectCache::FLD_TIME = 3 |
Definition at line 141 of file WANObjectCache.php.
const WANObjectCache::FLD_TTL = 2 |
Definition at line 140 of file WANObjectCache.php.
const WANObjectCache::FLD_VALUE = 1 |
Definition at line 139 of file WANObjectCache.php.
const WANObjectCache::FLD_VERSION = 0 |
Definition at line 138 of file WANObjectCache.php.
const WANObjectCache::HIT_RATE_HIGH = 1 |
Hits/second for a refresh to be expected within the "popularity" window.
Definition at line 117 of file WANObjectCache.php.
const WANObjectCache::HOLDOFF_NONE = 0 |
Idiom for delete() for "no hold-off".
Definition at line 128 of file WANObjectCache.php.
Referenced by WANObjectCacheTest\testDelete(), and WANObjectCacheTest\testGetMultiCheckKeys().
const WANObjectCache::HOLDOFF_TTL = 11 |
Seconds to tombstone keys on delete()
Definition at line 101 of file WANObjectCache.php.
Referenced by MessageCache\getValidationHash().
const WANObjectCache::HOT_TTR = 900 |
The time length of the "popularity" refresh window for hot keys.
Definition at line 115 of file WANObjectCache.php.
const WANObjectCache::INTERIM_KEY_PREFIX = 'WANCache:i:' |
Definition at line 155 of file WANObjectCache.php.
const WANObjectCache::LOCK_TSE = 1 |
Default time-since-expiry on a miss that makes a key "hot".
Definition at line 110 of file WANObjectCache.php.
const WANObjectCache::LOCK_TTL = 10 |
Seconds to keep lock keys around.
Definition at line 106 of file WANObjectCache.php.
const WANObjectCache::LOW_TTL = 30 |
Default remaining TTL at which to consider pre-emptive regeneration.
Definition at line 108 of file WANObjectCache.php.
const WANObjectCache::MAX_COMMIT_DELAY = 3 |
Max time expected to pass between delete() and DB commit finishing.
Definition at line 97 of file WANObjectCache.php.
const WANObjectCache::MAX_READ_LAG = 7 |
Max replication+snapshot lag before applying TTL_LAGGED or disallowing set()
Definition at line 99 of file WANObjectCache.php.
const WANObjectCache::MIN_TIMESTAMP_NONE = 0.0 |
Idiom for getWithSetCallback() for "no minimum required as-of timestamp".
Definition at line 130 of file WANObjectCache.php.
const WANObjectCache::MUTEX_KEY_PREFIX = 'WANCache:m:' |
Definition at line 157 of file WANObjectCache.php.
const WANObjectCache::PC_PRIMARY = 'primary:1000' |
Definition at line 164 of file WANObjectCache.php.
const WANObjectCache::PURGE_VAL_PREFIX = 'PURGED:' |
Definition at line 159 of file WANObjectCache.php.
Referenced by MessageBlobStoreTest\setUp(), and WANObjectCacheTest\testGetWithSeveralCheckKeys().
const WANObjectCache::RAMPUP_TTL = 30 |
Seconds to ramp up to the "popularity" refresh chance after a key is no longer new.
Definition at line 119 of file WANObjectCache.php.
const WANObjectCache::TIME_KEY_PREFIX = 'WANCache:t:' |
Definition at line 156 of file WANObjectCache.php.
Referenced by WANObjectCacheTest\testGetWithSeveralCheckKeys().
const WANObjectCache::TINY_NEGATIVE = -0.000001 |
Tiny negative float to use when CTL comes up >= 0 due to clock skew.
Definition at line 133 of file WANObjectCache.php.
const WANObjectCache::TSE_NONE = -1 |
Idiom for getWithSetCallback() callbacks to 'lockTSE' logic.
Definition at line 124 of file WANObjectCache.php.
const WANObjectCache::TTL_LAGGED = 30 |
Max TTL to store keys when a data sourced is lagged.
Definition at line 126 of file WANObjectCache.php.
const WANObjectCache::TTL_UNCACHEABLE = -1 |
Idiom for getWithSetCallback() callbacks to avoid calling set()
Definition at line 122 of file WANObjectCache.php.
Referenced by ForeignDBFile\getDescriptionText(), and File\getDescriptionText().
const WANObjectCache::VALUE_KEY_PREFIX = 'WANCache:v:' |
Definition at line 154 of file WANObjectCache.php.
const WANObjectCache::VERSION = 1 |
Cache format version number.
Definition at line 136 of file WANObjectCache.php.
const WANObjectCache::VFLD_DATA = 'WOC:d' |
Definition at line 161 of file WANObjectCache.php.
const WANObjectCache::VFLD_VERSION = 'WOC:v' |
Definition at line 162 of file WANObjectCache.php.