MediaWiki REL1_38
|
Multi-datacenter aware caching interface. More...
Public Member Functions | |
__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=[]) | |
Fetch the value of a key from cache. | |
getCheckKeyTime ( $key) | |
Fetch the value of a timestamp "check" key. | |
getLastError ( $watchPoint=0) | |
Get the "last error" registry. | |
getMulti (array $keys, &$curTTLs=[], array $checkKeys=[], &$info=[]) | |
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=[], array $cbParams=[]) | |
Method to fetch/regenerate a cache key. | |
hash256 ( $component) | |
Hash a possibly long string into a suitable component for makeKey()/makeGlobalKey() | |
makeGlobalKey ( $collection,... $components) | |
Make a cache key for the global keyspace and given components. | |
makeKey ( $collection,... $components) | |
Make a cache key using the "global" keyspace for the given components. | |
makeMultiKeys (array $ids, $keyCallback) | |
Get an iterator of (cache key => entity ID) for a list of entity IDs. | |
multiRemap (array $ids, array $res) | |
Get an (ID => value) map from (i) a non-unique list of entity IDs, and (ii) the list of corresponding entity values by first appearance of each ID in the entity ID list. | |
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) | |
Clear the last-purge timestamp of a "check" key in all datacenters. | |
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) | |
Increase the last-purge timestamp of a "check" key in all datacenters. | |
useInterimHoldOffCaching ( $enabled) | |
Enable or disable the use of brief caching for tombstoned keys. | |
watchErrors () | |
Get a "watch point" token that can be used to get the "last error" to occur after now. | |
Static Public Member Functions | |
static | getCollectionFromSisterKey (string $sisterKey) |
static | newEmpty () |
Get an instance that wraps EmptyBagOStuff. | |
Public Attributes | |
const | GRACE_TTL_NONE = 0 |
Idiom for set()/getWithSetCallback() meaning "no post-expiration grace period". | |
const | HOLDOFF_TTL = self::MAX_COMMIT_DELAY + self::MAX_READ_LAG + 1 |
Seconds to tombstone keys on delete() and to treat keys as volatile after purges. | |
const | HOLDOFF_TTL_NONE = 0 |
Idiom for delete()/touchCheckKey() meaning "no hold-off period". | |
const | KEY_AS_OF = 'asOf' |
Generation completion timestamp attribute for a key; keep value for b/c (< 1.36) | |
const | KEY_CHECK_AS_OF = 'lastCKPurge' |
Highest "check" key timestamp for a key; keep value for b/c (< 1.36) | |
const | KEY_CUR_TTL = 'curTTL' |
Remaining TTL attribute for a key; keep value for b/c (< 1.36) | |
const | KEY_TOMB_AS_OF = 'tombAsOf' |
Tomstone timestamp attribute for a key; keep value for b/c (< 1.36) | |
const | KEY_TTL = 'ttl' |
Logical TTL attribute for a key. | |
const | KEY_VERSION = 'version' |
Version number attribute for a key; keep value for b/c (< 1.36) | |
const | PASS_BY_REF = [] |
Idiom for get()/getMulti() to return extra information by reference. | |
const | STALE_TTL_NONE = 0 |
Idiom for set()/getWithSetCallback() meaning "no post-expiration persistence". | |
const | TTL_LAGGED = 30 |
Max TTL, in seconds, to store keys when a data source has high replication lag. | |
Public Attributes inherited from Wikimedia\LightweightObjectStore\StorageAwareness | |
const | ATTR_DURABILITY = 2 |
Durability of writes; see QOS_DURABILITY_* (higher means stronger) | |
const | ATTR_EMULATION = 1 |
Emulation/fallback mode; see QOS_EMULATION_*; higher is better. | |
const | ERR_NO_RESPONSE = 1 |
Storage medium failed to yield a complete response to an operation. | |
const | ERR_NONE = 0 |
No storage medium error. | |
const | ERR_UNEXPECTED = 3 |
Storage medium operation failed due to usage limitations or an I/O error. | |
const | ERR_UNREACHABLE = 2 |
Storage medium could not be reached to establish a connection. | |
const | QOS_DURABILITY_DISK = 4 |
Data is saved to disk and writes do not usually block on fsync() | |
const | QOS_DURABILITY_NONE = 1 |
Data is never saved to begin with (blackhole store) | |
const | QOS_DURABILITY_RDBMS = 5 |
Data is saved to disk and writes usually block on fsync(), like a standard RDBMS. | |
const | QOS_DURABILITY_SCRIPT = 2 |
Data is lost at the end of the current web request or CLI script. | |
const | QOS_DURABILITY_SERVICE = 3 |
Data is lost once the service storing the data restarts. | |
const | QOS_EMULATION_SQL = 1 |
Fallback disk-based SQL store. | |
const | QOS_UNKNOWN = INF |
Generic "unknown" value; useful for comparisons (always "good enough") | |
Protected Member Functions | |
fetchKeys (array $keys, array $checkKeys, $touchedCb=null) | |
Fetch the value and key metadata of several keys from cache. | |
getCurrentTime () | |
isLotteryRefreshDue ( $res, $lowTTL, $ageNew, $hotTTR, $now) | |
Check if a key is due for randomized regeneration due to near-expiration/popularity. | |
isValid ( $value, $asOf, $minAsOf) | |
Check that a wrapper value exists and has an acceptable age. | |
prependRoute (string $sisterKey, string $route) | |
relayNonVolatilePurge (string $sisterKey) | |
Remove a sister key from all datacenters. | |
relayVolatilePurges (array $purgeBySisterKey, int $ttl) | |
Set a sister key to a purge value in all datacenters. | |
worthRefreshExpiring ( $curTTL, $logicalTTL, $lowTTL) | |
Check if a key is nearing expiration and thus due for randomized regeneration. | |
worthRefreshPopular ( $asOf, $ageNew, $timeTillRefresh, $now) | |
Check if a key is due for randomized regeneration due to its popularity. | |
Protected Attributes | |
callable null | $asyncHandler |
Function that takes a WAN cache callback and runs it later. | |
string null | $broadcastRoute |
Routing prefix for operations that should be broadcasted to all data centers. | |
BagOStuff | $cache |
The local datacenter cache. | |
int | $coalesceScheme |
Scheme to use for key coalescing (Hash Tags or Hash Stops) | |
float | $epoch |
Unix timestamp of the oldest possible valid values. | |
LoggerInterface | $logger |
MapCacheLRU[] | $processCaches = [] |
Map of group PHP instance caches. | |
string | $secret |
Stable secret used for hasing long strings into key components. | |
StatsdDataFactoryInterface | $stats |
bool | $useInterimHoldOffCaching = true |
Whether to use "interim" caching while keys are tombstoned. | |
Private Member Functions | |
checkAndSetCooloff ( $key, $kClass, $value, $elapsed, $hasLock) | |
Check whether set() is rate-limited to avoid concurrent I/O spikes. | |
claimStampedeLock ( $key) | |
determineKeyClassForStats ( $key) | |
fetchOrRegenerate ( $key, $ttl, $callback, array $opts, array $cbParams) | |
Do the actual I/O for getWithSetCallback() when needed. | |
fetchWrappedValuesForWarmupCache (array $keys, array $checkKeys) | |
getInterimValue ( $key, $minAsOf, $now, $touchedCb) | |
getNonProcessCachedMultiKeys (ArrayIterator $keys, array $opts) | |
getProcessCache ( $group) | |
isAcceptablyFreshValue ( $res, $graceTTL, $minAsOf) | |
Check if a key value is non-false, new enough, and either fresh or "gracefully" stale. | |
isExtremelyNewValue ( $res, $minAsOf, $now) | |
Check if a key value is non-false, new enough, and has an "as of" time almost equal to now. | |
makeCheckPurgeValue (float $timestamp, int $holdoff, array &$purge=null) | |
makeSisterKey (string $baseKey, string $typeChar, string $route=null) | |
Get a sister key that should be collocated with a base cache key. | |
makeSisterKeys (array $baseKeys, string $type, string $route=null) | |
Get sister keys that should be collocated with their corresponding base cache keys. | |
makeTombstonePurgeValue (float $timestamp) | |
parsePurgeValue ( $value) | |
Extract purge metadata from cached value if it is a valid purge value. | |
processCheckKeys (array $checkSisterKeys, array $wrappedBySisterKey, float $now) | |
resolveBusyValue ( $busyValue) | |
scheduleAsyncRefresh ( $key, $ttl, $callback, array $opts, array $cbParams) | |
Schedule a deferred cache regeneration if possible. | |
setInterimValue ( $key, $value, $ttl, $version, $now, $walltime) | |
timeSinceLoggedMiss ( $key, $now) | |
unwrap ( $wrapped, $now) | |
wrap ( $value, $ttl, $version, $now, $walltime) | |
yieldStampedeLock ( $key, $hasLock) | |
Private Attributes | |
int | $callbackDepth = 0 |
Callback stack depth for getWithSetCallback() | |
int | $keyHighQps |
Reads/second assumed during a hypothetical cache write stampede for a key. | |
float | $keyHighUplinkBps |
Max tolerable bytes/second to spend on a cache write stampede for a key. | |
array< int, array > | $missLog |
List of (key, UNIX timestamp) tuples for get() cache misses. | |
float null | $wallClockOverride |
mixed[] | $warmupCache = [] |
Temporary warm-up cache. | |
int | $warmupKeyMisses = 0 |
Key fetched. | |
const | AGE_NEW = 60 |
Minimum key age, in seconds, for expected time-till-refresh to be considered. | |
const | CHECK_KEY_TTL = self::TTL_YEAR |
Seconds to keep dependency purge keys around. | |
const | COOLOFF_TTL = 1 |
Seconds to no-op key set() calls to avoid large blob I/O stampedes. | |
const | FLD_FLAGS = 4 |
Key to the flags bit field (reserved number) | |
const | FLD_FORMAT_VERSION = 0 |
Key to WAN cache version number; stored in blobs. | |
const | FLD_GENERATION_TIME = 6 |
Key to how long it took to generate the value; stored in blobs. | |
const | FLD_TIME = 3 |
Key to the cache timestamp; stored in blobs. | |
const | FLD_TTL = 2 |
Key to the original TTL; stored in blobs. | |
const | FLD_VALUE = 1 |
Key to the cached value; stored in blobs. | |
const | FLD_VALUE_VERSION = 5 |
Key to collection cache version number; stored in blobs. | |
const | GENERATION_HIGH_SEC = 0.2 |
Consider value generation somewhat high if it takes this many seconds or more. | |
const | GENERATION_SLOW_SEC = 3.0 |
Consider value generation slow if it takes this many seconds or more. | |
const | HOT_TTR = 900 |
Expected time-till-refresh, in seconds, if the key is accessed once per second. | |
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 |
Consider regeneration if the key will expire within this many seconds. | |
const | MAX_COMMIT_DELAY = 3 |
Max expected seconds to pass between delete() and DB commit finishing. | |
const | MAX_READ_LAG = 7 |
Max expected seconds of combined lag from replication and "view snapshots". | |
const | PC_PRIMARY = 'primary:1000' |
Default process cache name and max key count. | |
const | PURGE_HOLDOFF = 1 |
Key to the tombstone entry hold-off TTL. | |
const | PURGE_TIME = 0 |
Key to the tombstone entry timestamp. | |
const | PURGE_VAL_PREFIX = 'PURGED' |
Value prefix of purge values. | |
const | RAMPUP_TTL = 30 |
Seconds to ramp up the chance of regeneration due to expected time-till-refresh. | |
const | RECENT_SET_HIGH_MS = 100 |
Max millisecond set() backoff during hold-off (far less than INTERIM_KEY_TTL) | |
const | RECENT_SET_LOW_MS = 50 |
Min millisecond set() backoff during hold-off (far less than INTERIM_KEY_TTL) | |
const | RES_AS_OF = 2 |
Generation completion timestamp attribute for a key. | |
const | RES_CHECK_AS_OF = 5 |
Highest "check" key timestamp for a key. | |
const | RES_CUR_TTL = 7 |
Remaining TTL attribute for a key. | |
const | RES_TOMB_AS_OF = 4 |
Tomstone timestamp attribute for a key. | |
const | RES_TOUCH_AS_OF = 6 |
Highest "touched" timestamp for a key. | |
const | RES_TTL = 3 |
Logical TTL attribute for a key. | |
const | RES_VALUE = 0 |
Value for a key. | |
const | RES_VERSION = 1 |
Version number attribute for a key. | |
const | SCHEME_HASH_STOP = 2 |
Use mcrouter-style Hash Stop key scheme (e.g. | |
const | SCHEME_HASH_TAG = 1 |
Use twemproxy-style Hash Tag key scheme (e.g. | |
const | TSE_NONE = -1 |
Idiom for getWithSetCallback() meaning "no cache stampede mutex". | |
const | TYPE_COOLOFF = 'c' |
Single character component for cool-off bounce keys. | |
const | TYPE_INTERIM = 'i' |
Single character component for interium value keys. | |
const | TYPE_MUTEX = 'm' |
Single character component for mutex lock keys. | |
const | TYPE_TIMESTAMP = 't' |
Single character component for timestamp check keys. | |
const | TYPE_VALUE = 'v' |
Single character component for value keys. | |
const | VERSION = 1 |
Cache format version number. | |
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 primary or quorum reads.
To ensure consumers of the cache see new values in a timely manner, you either need to follow either the validation strategy, or the purge strategy.
The validation strategy refers to the natural avoidance of stale data by one of the following means:
The purge strategy refers to the approach whereby your application knows that source data has changed and can react by purging the relevant cache keys. As purges are expensive, this strategy should be avoided if possible. The simplest purge method is delete().
No matter which strategy you choose, callers must not rely on updates or purges being immediately visible to other servers. It should be treated similarly as one would a database replica.
The need for immediate updates should be avoided. If needed, solutions must be sought outside WANObjectCache.
There are two supported ways to set up broadcasted operations:
Broadcasted operations like delete() and touchCheckKey() are intended to run immediately in the local datacenter and asynchronously in remote datacenters.
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.
Internally, access to a given key actually involves the use of one or more "sister" keys. A sister key is constructed by prefixing the base key with "WANCache:" (used to distinguish WANObjectCache formatted keys) and suffixing a colon followed by a single-character sister key type. The sister key types include the following:
v
: used to store "regular" values (metadata-wrapped) and temporary purge "tombstones".t
: used to store "last purge" timestamps for "check" keys.m
: used to store temporary mutex locks to avoid cache stampedes.i
: used to store temporary interim values (metadata-wrapped) for tombstoned keys.c
: used to store temporary "cool-off" indicators, which specify a period during which values cannot be stored, neither regularly nor using interim keys.Definition at line 126 of file WANObjectCache.php.
WANObjectCache::__construct | ( | array | $params | ) |
array | $params |
|
Definition at line 345 of file WANObjectCache.php.
References setLogger().
WANObjectCache::adaptiveTTL | ( | $mtime, | |
$maxTTL, | |||
$minTTL = 30 , |
|||
$factor = 0.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:
Another use case is when there are no applicable "last modified" fields in the DB, and there are too many dependencies for explicit purges to be viable, and the rate of change to relevant content is unstable, and it is highly valued to have the cached value be as up-to-date as possible.
Example usage:
int | float | string | null | $mtime | UNIX timestamp; null if none |
int | $maxTTL | Maximum TTL (seconds) |
int | $minTTL | Minimum TTL (seconds); Default: 30 |
float | $factor | Value in the range (0,1); Default: .2 |
Definition at line 2597 of file WANObjectCache.php.
References getCurrentTime().
|
private |
Check whether set() is rate-limited to avoid concurrent I/O spikes.
This mitigates problems caused by popular keys suddenly becoming unavailable due to unexpected evictions or cache server outages. These cases are not handled by the usual preemptive refresh logic.
With a typical scale-out infrastructure, CPU and query load from getWithSetCallback() invocations is distributed among appservers and replica DBs, but cache operations for a given key route to a single cache server (e.g. striped consistent hashing). A set() stampede to a key can saturate the network link to its cache server. The intensity of the problem is proportionate to the value size and access rate. The duration of the problem is proportionate to value regeneration time.
string | $key | Cache key made with makeKey()/makeGlobalKey() |
string | $kClass | |
mixed | $value | The regenerated value |
float | $elapsed | Seconds spent fetching, validating, and regenerating the value |
bool | $hasLock | Whether this thread has an exclusive regeneration lock |
Definition at line 1870 of file WANObjectCache.php.
References makeSisterKey().
Referenced by fetchOrRegenerate().
|
private |
string | $key | Cache key made with makeKey()/makeGlobalKey() |
Definition at line 1745 of file WANObjectCache.php.
References makeSisterKey().
Referenced by fetchOrRegenerate().
|
final |
Clear the "last error" registry.
Definition at line 2488 of file WANObjectCache.php.
WANObjectCache::clearProcessCache | ( | ) |
Clear the in-process caches; useful for testing.
Definition at line 2497 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.
Be aware that this does not clear the process cache. Even if it did, callbacks used by getWithSetCallback() might still return stale data in the case of either uncommitted or not-yet-replicated changes (callback generally use replica DBs).
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, user-requested purges or cache cleanup scripts might not need to invoke a hold-off period on cache backfills, so they can use HOLDOFF_TTL_NONE.
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 made with makeKey()/makeGlobalKey() |
int | $ttl | Tombstone TTL; Default: WANObjectCache::HOLDOFF_TTL |
Definition at line 974 of file WANObjectCache.php.
References determineKeyClassForStats(), getCurrentTime(), makeSisterKey(), makeTombstonePurgeValue(), relayNonVolatilePurge(), and relayVolatilePurges().
|
private |
string | $key | String of the format <scope>:<collection>[:<constant or variable>]... |
Definition at line 2958 of file WANObjectCache.php.
Referenced by delete(), fetchOrRegenerate(), resetCheckKey(), and touchCheckKey().
|
protected |
Fetch the value and key metadata of several keys from cache.
$checkKeys holds the "check" keys used to validate values of applicable keys. The integer indexes hold "check" keys that apply to all of $keys while the string indexes hold "check" keys that only apply to the cache key with that name.
string[] | $keys | List/map with makeKey()/makeGlobalKey() cache keys as values |
string[] | string[][] | $checkKeys | Map of (integer or cache key => "check" key(s)); "check" keys must also be made with makeKey()/makeGlobalKey() |
callable | null | $touchedCb | Callback yielding a UNIX timestamp from a value, or null |
Definition at line 552 of file WANObjectCache.php.
References $keys, $res, getCurrentTime(), makeSisterKey(), processCheckKeys(), and unwrap().
Referenced by fetchOrRegenerate(), get(), getMulti(), and getMultiWithUnionSetCallback().
|
private |
Do the actual I/O for getWithSetCallback() when needed.
string | $key | Cache key made with makeKey()/makeGlobalKey() |
int | $ttl | |
callable | $callback | |
array | $opts | |
array | $cbParams |
Definition at line 1558 of file WANObjectCache.php.
References checkAndSetCooloff(), claimStampedeLock(), determineKeyClassForStats(), fetchKeys(), getCurrentTime(), getInterimValue(), isAcceptablyFreshValue(), isExtremelyNewValue(), isLotteryRefreshDue(), isValid(), resolveBusyValue(), scheduleAsyncRefresh(), setInterimValue(), and yieldStampedeLock().
Referenced by getWithSetCallback(), and scheduleAsyncRefresh().
|
private |
string[] | $keys | Cache keys made with makeKey()/makeGlobalKey() |
string[] | string[][] | $checkKeys | Map of (integer or cache key => "check" key(s)); "check" keys must also be made with makeKey()/makeGlobalKey() |
Definition at line 3062 of file WANObjectCache.php.
References $keys, makeSisterKey(), and makeSisterKeys().
Referenced by getMultiWithSetCallback(), and getMultiWithUnionSetCallback().
|
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 key purges 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(), which has cache slam avoidance and key versioning features, instead of bare get()/set() calls.
Do not use this method on versioned keys accessed via getWithSetCallback().
When using the $info parameter, it should be passed in as WANObjectCache::PASS_BY_REF. In that case, it becomes a key metadata map. Otherwise, for backwards compatibility, $info becomes the value generation timestamp (null if the key is nonexistant/tombstoned). Key metadata map fields include:
string | $key | Cache key made with makeKey()/makeGlobalKey() |
float | null | &$curTTL | Seconds of TTL left [returned] |
string[] | $checkKeys | Map of (integer or cache key => "check" key(s)); "check" keys must also be made with makeKey()/makeGlobalKey() |
array | &$info | Metadata map [returned] |
Definition at line 447 of file WANObjectCache.php.
References $res, fetchKeys(), and getCurrentTime().
|
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 | Cache key made with makeKey()/makeGlobalKey() |
Definition at line 1023 of file WANObjectCache.php.
References getMultiCheckKeyTime().
|
static |
string | $sisterKey | Sister key from makeSisterKey() |
Definition at line 1813 of file WANObjectCache.php.
|
protected |
Definition at line 3108 of file WANObjectCache.php.
Referenced by adaptiveTTL(), delete(), fetchKeys(), fetchOrRegenerate(), get(), getMultiCheckKeyTime(), set(), touchCheckKey(), and yieldStampedeLock().
|
private |
string | $key | Cache key made with makeKey()/makeGlobalKey() |
float | $minAsOf | Minimum acceptable value "as of" UNIX timestamp |
float | $now | Fetch time to determine "age" metadata |
callable | null | $touchedCb | Function to find the max "dependency touched" UNIX timestamp |
Definition at line 1928 of file WANObjectCache.php.
References $res, makeSisterKey(), unwrap(), and useInterimHoldOffCaching().
Referenced by fetchOrRegenerate().
|
final |
Get the "last error" registry.
The method should be invoked by a caller as part of the following pattern:
External callers can also invoke this method as part of the following pattern:
int | $watchPoint | Only consider errors from after this "watch point" [optional] |
Definition at line 2470 of file WANObjectCache.php.
|
final |
Fetch the value of several keys from cache.
$curTTLs becomes a map of only present/tombstoned $keys to their current time-to-live.
$checkKeys holds the "check" keys used to validate values of applicable keys. The integer indexes hold "check" keys that apply to all of $keys while the string indexes hold "check" keys that only apply to the cache key with that name. The logic of "check" keys otherwise works the same as in WANObjectCache::get().
When using the $info parameter, it should be passed in as WANObjectCache::PASS_BY_REF. In that case, it becomes a mapping of all the $keys to their metadata maps, each in the style of WANObjectCache::get(). Otherwise, for backwards compatibility, $info becomes a map of only present/tombstoned $keys to their value generation timestamps.
string[] | $keys | List/map with makeKey()/makeGlobalKey() cache keys as values |
array<string,float> | &$curTTLs Map of (key => seconds of TTL left) [returned] | |
string[] | string[][] | $checkKeys | Map of (integer or cache key => "check" key(s)); "check" keys must also be made with makeKey()/makeGlobalKey() |
array<string,array> | &$info Map of (key => metadata map) [returned] |
Definition at line 500 of file WANObjectCache.php.
References $keys, $res, and fetchKeys().
|
final |
Fetch the values of each timestamp "check" key.
This works like getCheckKeyTime() except it takes a list of keys and returns a map of timestamps instead of just that of one key
This might be useful if both:
The later entities can each use a "check" key to purge their dependee entities. However, it is expensive for the former entities to verify against all of the relevant "check" keys during each getWithSetCallback() call. A less expensive approach is to do these verifications only after a "time-till-verify" (TTV) has passed. This is a middle ground between using blind TTLs and using constant verification. The adaptiveTTL() method can be used to dynamically adjust the TTV. Also, the initial TTV can make use of the last-modified times of the dependent entities (either from the DB or the "check" keys).
Example usage:
string[] | $keys | Cache keys made with makeKey()/makeGlobalKey() |
Definition at line 1088 of file WANObjectCache.php.
References $keys, getCurrentTime(), makeCheckPurgeValue(), makeSisterKey(), and parsePurgeValue().
Referenced by getCheckKeyTime().
|
final |
Method to fetch multiple cache keys at once with regeneration.
This works the same as getWithSetCallback() except:
Example usage:
ArrayIterator | $keyedIds | Result of WANObjectCache::makeMultiKeys() |
int | $ttl | Seconds to live for key updates |
callable | $callback | Callback that yields entity generation callbacks |
array | $opts | Options map similar to that of getWithSetCallback() |
Definition at line 2044 of file WANObjectCache.php.
References fetchWrappedValuesForWarmupCache(), getNonProcessCachedMultiKeys(), and getWithSetCallback().
|
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() |
int | $ttl | Seconds to live for key updates |
callable | $callback | Callback that yields entity generation callbacks |
array | $opts | Options map similar to that of getWithSetCallback() |
Definition at line 2145 of file WANObjectCache.php.
References $res, fetchKeys(), fetchWrappedValuesForWarmupCache(), getNonProcessCachedMultiKeys(), and getWithSetCallback().
|
private |
ArrayIterator | $keys | |
array | $opts |
Definition at line 3040 of file WANObjectCache.php.
References $keys, and getProcessCache().
Referenced by getMultiWithSetCallback(), and getMultiWithUnionSetCallback().
|
private |
string | $group |
Definition at line 3023 of file WANObjectCache.php.
Referenced by getNonProcessCachedMultiKeys(), and getWithSetCallback().
WANObjectCache::getQoS | ( | $flag | ) |
int | $flag | ATTR_* class constant |
Definition at line 2530 of file WANObjectCache.php.
Referenced by MediaWiki\Storage\SqlBlobStore\getCacheTTL().
|
final |
Definition at line 2612 of file WANObjectCache.php.
|
final |
Method to fetch/regenerate a cache key.
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 $ttl argument and "hotTTR" option (in $opts) use time-dependent randomization to avoid stampedes. Keys that are slow to regenerate and either heavily used or subject to explicit (unpredictable) purges, may need additional mechanisms. The simplest way to avoid stampedes for such keys is to use 'lockTSE' (in $opts). If explicit purges are needed, also:
This applies cache server I/O stampede protection against duplicate cache sets. This is important when the callback is slow and/or yields large values for a key.
Example usage (typical key):
Example usage (key that is expensive and hot):
Example usage (key with dynamic dependencies):
Example usage (key that is expensive with too many DB dependencies for "check" keys):
Example usage (hot key holding most recent 100 events):
Example usage (key holding an LRU subkey:value map; this can avoid flooding cache with keys for an unlimited set of (constraint,situation) pairs, thereby avoiding elevated cache evictions and wasted memory):
string | $key | Cache key made with makeKey()/makeGlobalKey() |
int | $ttl | Nominal seconds-to-live for newly computed values. Special values are:
|
callable | $callback | Value generation function |
array | $opts | Options map:
|
array | $cbParams | Custom field/value map to pass to the callback (since 1.35) @phpcs:ignore Generic.Files.LineLength |
Definition at line 1498 of file WANObjectCache.php.
References $res, fetchOrRegenerate(), getProcessCache(), and makeGlobalKey().
Referenced by getMultiWithSetCallback(), and getMultiWithUnionSetCallback().
WANObjectCache::hash256 | ( | $component | ) |
Hash a possibly long string into a suitable component for makeKey()/makeGlobalKey()
string | $component | A raw component used in building a cache key |
Definition at line 2320 of file WANObjectCache.php.
|
private |
Check if a key value is non-false, new enough, and either fresh or "gracefully" stale.
array | $res | Current value WANObjectCache::RES_* data map |
int | $graceTTL | Consider using stale values if $curTTL is greater than this |
float | $minAsOf | Minimum acceptable value "as of" UNIX timestamp |
Definition at line 2728 of file WANObjectCache.php.
References $res, isValid(), and worthRefreshExpiring().
Referenced by fetchOrRegenerate().
|
private |
Check if a key value is non-false, new enough, and has an "as of" time almost equal to now.
If the value was just written to cache, and it did not take an unusually long time to generate, then it is probably not worth regenerating yet. For example, replica databases might still return lagged pre-purge values anyway.
array | $res | Current value WANObjectCache::RES_* data map |
float | $minAsOf | Minimum acceptable value "as of" UNIX timestamp |
float | $now | Current UNIX timestamp |
Definition at line 1839 of file WANObjectCache.php.
References $res.
Referenced by fetchOrRegenerate().
|
protected |
Check if a key is due for randomized regeneration due to near-expiration/popularity.
array | $res | Current value WANObjectCache::RES_* data map |
float | $lowTTL | Consider a refresh when $curTTL is less than this; the "low" threshold |
int | $ageNew | Age of key when this might recommend refreshing (seconds) |
int | $hotTTR | Age of key when it should be refreshed if popular (seconds) |
float | $now | The current UNIX timestamp |
Definition at line 2760 of file WANObjectCache.php.
References $res, worthRefreshExpiring(), and worthRefreshPopular().
Referenced by fetchOrRegenerate().
|
protected |
Check that a wrapper value exists and has an acceptable age.
array | false | $value | Value wrapper or false |
float | $asOf | Value generation "as of" timestamp |
float | $minAsOf | Minimum acceptable value "as of" UNIX timestamp |
Definition at line 2860 of file WANObjectCache.php.
Referenced by fetchOrRegenerate(), and isAcceptablyFreshValue().
|
private |
float | $timestamp | UNIX timestamp |
int | $holdoff | In seconds |
array | null | &$purge | Unwrapped purge value array [returned] |
Definition at line 3011 of file WANObjectCache.php.
Referenced by getMultiCheckKeyTime(), processCheckKeys(), and touchCheckKey().
WANObjectCache::makeGlobalKey | ( | $collection, | |
$components | |||
) |
Make a cache key for the global keyspace and given components.
string | $collection | Key collection name component |
string|int | ...$components Additional, ordered, key components for entity IDs |
Implements IStoreKeyEncoder.
Definition at line 2295 of file WANObjectCache.php.
Referenced by getWithSetCallback().
WANObjectCache::makeKey | ( | $collection, | |
$components | |||
) |
Make a cache key using the "global" keyspace for the given components.
string | $collection | Key collection name component |
string|int | ...$components Additional, ordered, key components for entity IDs |
Implements IStoreKeyEncoder.
Definition at line 2309 of file WANObjectCache.php.
|
final |
Get an iterator of (cache key => entity ID) for a list of entity IDs.
The callback takes an ID string and returns a key via makeKey()/makeGlobalKey(). There should be no network nor filesystem I/O used in the callback. The entity ID/key mapping must be 1:1 or an exception will be thrown. If hashing is needed, then use the hash256() method.
Example usage for the default keyspace:
Example usage for mixed default and global keyspace:
Example usage with hashing:
string[] | int[] | $ids | List of entity IDs |
callable | $keyCallback | Function returning makeKey()/makeGlobalKey() on the input ID |
UnexpectedValueException |
Definition at line 2374 of file WANObjectCache.php.
|
private |
Get a sister key that should be collocated with a base cache key.
The keys will bear the WANCache prefix and use the configured coalescing scheme
string | $baseKey | Cache key made with makeKey()/makeGlobalKey() |
string | $typeChar | Consistent hashing agnostic suffix character matching [a-zA-Z] |
string | null | $route | Routing prefix (optional) |
Definition at line 1791 of file WANObjectCache.php.
References prependRoute().
Referenced by checkAndSetCooloff(), claimStampedeLock(), delete(), fetchKeys(), fetchWrappedValuesForWarmupCache(), getInterimValue(), getMultiCheckKeyTime(), makeSisterKeys(), reap(), reapCheckKey(), resetCheckKey(), set(), setInterimValue(), touchCheckKey(), and yieldStampedeLock().
|
private |
Get sister keys that should be collocated with their corresponding base cache keys.
The key will bear the WANCache prefix and use the configured coalescing scheme
string[] | $baseKeys | Cache keys made with makeKey()/makeGlobalKey() |
string | $type | Consistent hashing agnostic suffix character matching [a-zA-Z] |
string | null | $route | Routing prefix (optional) |
Definition at line 1772 of file WANObjectCache.php.
References $type, and makeSisterKey().
Referenced by fetchWrappedValuesForWarmupCache().
|
private |
float | $timestamp | UNIX timestamp |
Definition at line 3001 of file WANObjectCache.php.
Referenced by delete().
|
final |
Get an (ID => value) map from (i) a non-unique list of entity IDs, and (ii) the list of corresponding entity values by first appearance of each ID in the entity ID list.
For use with getMultiWithSetCallback() and getMultiWithUnionSetCallback().
Only use this method if the entity ID/key mapping is trivially 1:1 without exception. Key generation method must utitilize the full entity ID in the key (not a hash of it).
Example usage:
string[] | int[] | $ids | Entity ID list makeMultiKeys() |
mixed[] | $res | Result of getMultiWithSetCallback()/getMultiWithUnionSetCallback() |
Definition at line 2430 of file WANObjectCache.php.
References $res.
|
static |
Get an instance that wraps EmptyBagOStuff.
Definition at line 388 of file WANObjectCache.php.
|
private |
Extract purge metadata from cached value if it is a valid purge value.
Valid purge values come from makeTombstonePurgeValue()/makeCheckKeyPurgeValue()
mixed | $value | Cached value |
Definition at line 2973 of file WANObjectCache.php.
Referenced by getMultiCheckKeyTime(), processCheckKeys(), reapCheckKey(), and unwrap().
|
protected |
string | $sisterKey | |
string | $route | Key routing prefix |
Definition at line 2674 of file WANObjectCache.php.
Referenced by makeSisterKey(), relayNonVolatilePurge(), and relayVolatilePurges().
|
private |
string[] | $checkSisterKeys | List of "check" sister keys |
mixed[] | $wrappedBySisterKey | Preloaded map of (sister key => wrapped value) |
float | $now | UNIX timestamp |
Definition at line 680 of file WANObjectCache.php.
References makeCheckPurgeValue(), and parsePurgeValue().
Referenced by fetchKeys().
|
final |
Set a key to soon expire in the local cluster if it pre-dates $purgeTimestamp.
This sets stale keys' time-to-live at HOLDOFF_TTL seconds, which both avoids broadcasting in mcrouter setups and also avoids races with new tombstones.
string | $key | Cache key made with makeKey()/makeGlobalKey() |
int | float | $purgeTimestamp | UNIX timestamp of purge |
bool | &$isStale | Whether the key is stale |
Definition at line 2233 of file WANObjectCache.php.
References makeSisterKey().
|
final |
Set a "check" key to soon expire in the local cluster if it pre-dates $purgeTimestamp.
string | $key | Cache key made with makeKey()/makeGlobalKey() |
int | $purgeTimestamp | UNIX timestamp of purge |
bool | &$isStale | Whether the key is stale |
Definition at line 2264 of file WANObjectCache.php.
References makeSisterKey(), and parsePurgeValue().
|
protected |
Remove a sister key from all datacenters.
This method should not wait for the operation to complete on remote datacenters
string | $sisterKey | A value key or "check" key |
Definition at line 2659 of file WANObjectCache.php.
References prependRoute().
Referenced by delete(), and resetCheckKey().
|
protected |
Set a sister key to a purge value in all datacenters.
This method should not wait for the operation to complete on remote datacenters
Since older purge values can sometimes arrive after newer ones, use a relative expiry so that even if the older value replaces the newer value, the TTL will greater than the remaining TTL on the older value (assuming that all purges for a key use the same TTL).
array<string,string> | $purgeBySisterKey Map of (sister key => result of makeTombstonePurgeValue()/makeCheckKeyPurgeValue()) | |
int | $ttl | Seconds to keep the purge value around |
Definition at line 2630 of file WANObjectCache.php.
References prependRoute().
Referenced by delete(), and touchCheckKey().
|
final |
Clear the last-purge timestamp of a "check" key in all datacenters.
Similar to touchCheckKey(), in that keys fetched using get*() calls, that include the given "check" key, will be seen as purged. However, there are some differences:
The advantage over touchCheckKey() is that the "check" keys, which have high TTLs, will only be created when a get*() method actually uses those keys. This is better when a large number of "check" keys must be changed in a short period of time.
Note that "check" keys won't collide with other regular keys.
string | $key | Cache key made with makeKey()/makeGlobalKey() |
Definition at line 1185 of file WANObjectCache.php.
References determineKeyClassForStats(), makeSisterKey(), and relayNonVolatilePurge().
|
private |
mixed | $busyValue |
Definition at line 1976 of file WANObjectCache.php.
Referenced by fetchOrRegenerate().
|
private |
Schedule a deferred cache regeneration if possible.
string | $key | Cache key made with makeKey()/makeGlobalKey() |
int | $ttl | Seconds to live |
callable | $callback | |
array | $opts | |
array | $cbParams |
Definition at line 2693 of file WANObjectCache.php.
References fetchOrRegenerate().
Referenced by fetchOrRegenerate().
|
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 data was read using "view snapshots" (e.g. innodb REPEATABLE-READ), use 'since' to avoid the following race condition:
Setting 'lag' and 'since' help avoids keys getting stuck in stale states.
Be aware that this does not update the process cache for getWithSetCallback() callers. Keys accessed via that method are not generally meant to also be set using this primitive method.
Consider using getWithSetCallback(), which has cache slam avoidance and key versioning features, instead of bare get()/set() calls.
Do not use this method on versioned keys accessed via getWithSetCallback().
Example usage:
string | $key | Cache key made with makeKey()/makeGlobalKey() |
mixed | $value | Value to set for the cache key |
int | $ttl | Seconds to live. Special values are:
|
array | $opts | Options map:
|
Definition at line 783 of file WANObjectCache.php.
References $cache, getCurrentTime(), makeSisterKey(), timeSinceLoggedMiss(), and wrap().
Referenced by MessageBlobStore\recacheMessageBlob().
|
private |
string | $key | Cache key made with makeKey()/makeGlobalKey() |
mixed | $value | |
int | $ttl | |
int | null | $version | Value version number |
float | $now | Time after value regen |
float | $walltime | How long it took to generate the value in seconds |
Definition at line 1958 of file WANObjectCache.php.
References makeSisterKey(), and wrap().
Referenced by fetchOrRegenerate().
WANObjectCache::setLogger | ( | LoggerInterface | $logger | ) |
LoggerInterface | $logger |
Definition at line 379 of file WANObjectCache.php.
Referenced by __construct().
WANObjectCache::setMockTime | ( | & | $time | ) |
float | null | &$time | Mock UNIX timestamp for testing |
Definition at line 3126 of file WANObjectCache.php.
|
private |
string | $key | Cache key made with makeKey()/makeGlobalKey() |
float | $now | Current UNIX timestamp |
Definition at line 3094 of file WANObjectCache.php.
Referenced by set().
|
final |
Increase the last-purge timestamp of a "check" key in all datacenters.
This method should only be called when some heavily referenced data changes in a significant way, such that it is impractical to call delete() on all the cache keys that should be purged. The get*() method calls used to fetch these keys must include the given "check" key in the relevant "check" keys argument/option.
A "check" key essentially represents a last-modified time of an entity. When the key is touched, the timestamp will be updated to the current time. Keys fetched using get*() calls, that include the "check" key, will be seen as purged.
The timestamp of the "check" key is treated as being HOLDOFF_TTL seconds in the future by get*() methods in order to avoid race conditions where keys are updated with stale values (e.g. from a lagged replica DB). A high TTL is set on the "check" key, making it possible to know the timestamp of the last change to the corresponding entities in most cases. This might use more cache space than resetCheckKey().
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 made with makeKey()/makeGlobalKey() |
int | $holdoff | HOLDOFF_TTL or HOLDOFF_TTL_NONE constant |
Definition at line 1145 of file WANObjectCache.php.
References determineKeyClassForStats(), getCurrentTime(), makeCheckPurgeValue(), makeSisterKey(), and relayVolatilePurges().
|
private |
array | string | false | $wrapped | The entry at a cache key (false if key is nonexistant) |
float | $now | Unix Current timestamp (preferrably pre-query) |
Definition at line 2905 of file WANObjectCache.php.
References $res, and parsePurgeValue().
Referenced by fetchKeys(), and getInterimValue().
|
final |
Enable or disable the use of brief caching for tombstoned keys.
When a key is purged via delete(), there normally is a period where caching is hold-off limited to an extremely short time. This method will disable that caching, forcing the callback to run for any of:
This is useful when both:
bool | $enabled | Whether to enable interim caching |
Definition at line 2521 of file WANObjectCache.php.
References useInterimHoldOffCaching().
Referenced by getInterimValue(), and useInterimHoldOffCaching().
WANObjectCache::watchErrors | ( | ) |
Get a "watch point" token that can be used to get the "last error" to occur after now.
Definition at line 2449 of file WANObjectCache.php.
|
protected |
Check if a key is nearing expiration and thus due for randomized regeneration.
If $curTTL is greater than the "low" threshold (e.g. not nearing expiration) then this returns false. If $curTTL <= 0 (e.g. value already expired), then this returns false. Otherwise, the chance of this returning true increases steadily from 0% to 100% as $curTTL moves from the "low" threshold down to 0 seconds.
The logical TTL will be used as the "low" threshold if it is less than $lowTTL.
This method uses deadline-aware randomization in order to handle wide variations of cache access traffic without the need for configuration or expensive state.
float | $curTTL | Approximate TTL left on the key |
float | $logicalTTL | Full logical TTL assigned to the key |
float | $lowTTL | Consider a refresh when $curTTL is less than this; the "low" threshold |
Definition at line 2832 of file WANObjectCache.php.
Referenced by isAcceptablyFreshValue(), and isLotteryRefreshDue().
|
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 |
int | $ageNew | Age of key when this might recommend refreshing (seconds) |
int | $timeTillRefresh | Age of key when it should be refreshed if popular (seconds) |
float | $now | The current UNIX timestamp |
Definition at line 2786 of file WANObjectCache.php.
Referenced by isLotteryRefreshDue().
|
private |
mixed | $value | |
int | $ttl | Seconds to live or zero for "indefinite" |
int | null | $version | Value version number or null if not versioned |
float | $now | Unix Current timestamp just before calling set() |
float | null | $walltime | How long it took to generate the value in seconds |
Definition at line 2872 of file WANObjectCache.php.
Referenced by set(), and setInterimValue().
|
private |
string | $key | Cache key made with makeKey()/makeGlobalKey() |
bool | $hasLock |
Definition at line 1755 of file WANObjectCache.php.
References getCurrentTime(), and makeSisterKey().
Referenced by fetchOrRegenerate().
|
protected |
Function that takes a WAN cache callback and runs it later.
Definition at line 141 of file WANObjectCache.php.
|
protected |
Routing prefix for operations that should be broadcasted to all data centers.
If null, the there is only one datacenter or a backend proxy broadcasts everything.
Definition at line 150 of file WANObjectCache.php.
|
protected |
The local datacenter cache.
Definition at line 133 of file WANObjectCache.php.
|
private |
Callback stack depth for getWithSetCallback()
Definition at line 169 of file WANObjectCache.php.
|
protected |
Scheme to use for key coalescing (Hash Tags or Hash Stops)
Definition at line 158 of file WANObjectCache.php.
|
protected |
Unix timestamp of the oldest possible valid values.
Definition at line 154 of file WANObjectCache.php.
|
private |
Reads/second assumed during a hypothetical cache write stampede for a key.
Definition at line 161 of file WANObjectCache.php.
|
private |
Max tolerable bytes/second to spend on a cache write stampede for a key.
Definition at line 163 of file WANObjectCache.php.
|
protected |
Definition at line 137 of file WANObjectCache.php.
|
private |
List of (key, UNIX timestamp) tuples for get() cache misses.
Definition at line 166 of file WANObjectCache.php.
|
protected |
Map of group PHP instance caches.
Definition at line 135 of file WANObjectCache.php.
|
protected |
Stable secret used for hasing long strings into key components.
Definition at line 156 of file WANObjectCache.php.
|
protected |
Definition at line 139 of file WANObjectCache.php.
|
protected |
Whether to use "interim" caching while keys are tombstoned.
Definition at line 152 of file WANObjectCache.php.
|
private |
Definition at line 176 of file WANObjectCache.php.
|
private |
Temporary warm-up cache.
Definition at line 171 of file WANObjectCache.php.
|
private |
Key fetched.
Definition at line 173 of file WANObjectCache.php.
|
private |
Minimum key age, in seconds, for expected time-till-refresh to be considered.
Definition at line 193 of file WANObjectCache.php.
|
private |
Seconds to keep dependency purge keys around.
Definition at line 220 of file WANObjectCache.php.
|
private |
Seconds to no-op key set() calls to avoid large blob I/O stampedes.
Definition at line 227 of file WANObjectCache.php.
|
private |
Key to the flags bit field (reserved number)
@noinspection PhpUnusedPrivateFieldInspection
Definition at line 293 of file WANObjectCache.php.
|
private |
Key to WAN cache version number; stored in blobs.
Definition at line 285 of file WANObjectCache.php.
|
private |
Key to how long it took to generate the value; stored in blobs.
Definition at line 297 of file WANObjectCache.php.
|
private |
Key to the cache timestamp; stored in blobs.
Definition at line 291 of file WANObjectCache.php.
|
private |
Key to the original TTL; stored in blobs.
Definition at line 289 of file WANObjectCache.php.
|
private |
Key to the cached value; stored in blobs.
Definition at line 287 of file WANObjectCache.php.
|
private |
Key to collection cache version number; stored in blobs.
Definition at line 295 of file WANObjectCache.php.
|
private |
Consider value generation somewhat high if it takes this many seconds or more.
Definition at line 242 of file WANObjectCache.php.
|
private |
Consider value generation slow if it takes this many seconds or more.
Definition at line 244 of file WANObjectCache.php.
const WANObjectCache::GRACE_TTL_NONE = 0 |
Idiom for set()/getWithSetCallback() meaning "no post-expiration grace period".
Definition at line 201 of file WANObjectCache.php.
const WANObjectCache::HOLDOFF_TTL = self::MAX_COMMIT_DELAY + self::MAX_READ_LAG + 1 |
Seconds to tombstone keys on delete() and to treat keys as volatile after purges.
Definition at line 183 of file WANObjectCache.php.
const WANObjectCache::HOLDOFF_TTL_NONE = 0 |
Idiom for delete()/touchCheckKey() meaning "no hold-off period".
Definition at line 203 of file WANObjectCache.php.
|
private |
Expected time-till-refresh, in seconds, if the key is accessed once per second.
Definition at line 191 of file WANObjectCache.php.
|
private |
Seconds to keep interim value keys for tombstoned keys around.
Definition at line 222 of file WANObjectCache.php.
const WANObjectCache::KEY_AS_OF = 'asOf' |
Generation completion timestamp attribute for a key; keep value for b/c (< 1.36)
Definition at line 257 of file WANObjectCache.php.
const WANObjectCache::KEY_CHECK_AS_OF = 'lastCKPurge' |
Highest "check" key timestamp for a key; keep value for b/c (< 1.36)
Definition at line 265 of file WANObjectCache.php.
const WANObjectCache::KEY_CUR_TTL = 'curTTL' |
Remaining TTL attribute for a key; keep value for b/c (< 1.36)
Definition at line 261 of file WANObjectCache.php.
const WANObjectCache::KEY_TOMB_AS_OF = 'tombAsOf' |
Tomstone timestamp attribute for a key; keep value for b/c (< 1.36)
Definition at line 263 of file WANObjectCache.php.
const WANObjectCache::KEY_TTL = 'ttl' |
Logical TTL attribute for a key.
Definition at line 259 of file WANObjectCache.php.
const WANObjectCache::KEY_VERSION = 'version' |
Version number attribute for a key; keep value for b/c (< 1.36)
Definition at line 255 of file WANObjectCache.php.
|
private |
Seconds to keep lock keys around.
Definition at line 225 of file WANObjectCache.php.
|
private |
Consider regeneration if the key will expire within this many seconds.
Definition at line 186 of file WANObjectCache.php.
|
private |
Max expected seconds to pass between delete() and DB commit finishing.
Definition at line 179 of file WANObjectCache.php.
|
private |
Max expected seconds of combined lag from replication and "view snapshots".
Definition at line 181 of file WANObjectCache.php.
const WANObjectCache::PASS_BY_REF = [] |
Idiom for get()/getMulti() to return extra information by reference.
Definition at line 212 of file WANObjectCache.php.
|
private |
Default process cache name and max key count.
Definition at line 209 of file WANObjectCache.php.
|
private |
Key to the tombstone entry hold-off TTL.
Definition at line 249 of file WANObjectCache.php.
|
private |
Key to the tombstone entry timestamp.
Definition at line 247 of file WANObjectCache.php.
|
private |
Value prefix of purge values.
Definition at line 311 of file WANObjectCache.php.
|
private |
Seconds to ramp up the chance of regeneration due to expected time-till-refresh.
Definition at line 229 of file WANObjectCache.php.
|
private |
Max millisecond set() backoff during hold-off (far less than INTERIM_KEY_TTL)
Definition at line 239 of file WANObjectCache.php.
|
private |
Min millisecond set() backoff during hold-off (far less than INTERIM_KEY_TTL)
Definition at line 237 of file WANObjectCache.php.
|
private |
Generation completion timestamp attribute for a key.
Definition at line 272 of file WANObjectCache.php.
|
private |
Highest "check" key timestamp for a key.
Definition at line 278 of file WANObjectCache.php.
|
private |
Remaining TTL attribute for a key.
Definition at line 282 of file WANObjectCache.php.
|
private |
Tomstone timestamp attribute for a key.
Definition at line 276 of file WANObjectCache.php.
|
private |
Highest "touched" timestamp for a key.
Definition at line 280 of file WANObjectCache.php.
|
private |
Logical TTL attribute for a key.
Definition at line 274 of file WANObjectCache.php.
|
private |
Value for a key.
Definition at line 268 of file WANObjectCache.php.
|
private |
Version number attribute for a key.
Definition at line 270 of file WANObjectCache.php.
|
private |
Use mcrouter-style Hash Stop key scheme (e.g.
"...|#|")
Definition at line 217 of file WANObjectCache.php.
|
private |
Use twemproxy-style Hash Tag key scheme (e.g.
"{...}")
Definition at line 215 of file WANObjectCache.php.
const WANObjectCache::STALE_TTL_NONE = 0 |
Idiom for set()/getWithSetCallback() meaning "no post-expiration persistence".
Definition at line 199 of file WANObjectCache.php.
|
private |
Idiom for getWithSetCallback() meaning "no cache stampede mutex".
Definition at line 196 of file WANObjectCache.php.
const WANObjectCache::TTL_LAGGED = 30 |
Max TTL, in seconds, to store keys when a data source has high replication lag.
Definition at line 188 of file WANObjectCache.php.
|
private |
Single character component for cool-off bounce keys.
Definition at line 308 of file WANObjectCache.php.
|
private |
Single character component for interium value keys.
Definition at line 306 of file WANObjectCache.php.
|
private |
Single character component for mutex lock keys.
Definition at line 304 of file WANObjectCache.php.
|
private |
Single character component for timestamp check keys.
Definition at line 302 of file WANObjectCache.php.
|
private |
Single character component for value keys.
Definition at line 300 of file WANObjectCache.php.
|
private |
Cache format version number.
Definition at line 252 of file WANObjectCache.php.