Merge "Title: Title::getSubpage should not lose the interwiki prefix"
[lhc/web/wiklou.git] / includes / libs / objectcache / README.md
1 # wikimedia/objectcache
2
3 ## Statistics
4
5 Sent to StatsD under MediaWiki's namespace.
6
7 ### WANObjectCache
8
9 The default WANObjectCache provided by MediaWikiServices disables these
10 statistics in processes where `$wgCommandLineMode` is true.
11
12 #### `wanobjectcache.{kClass}.{cache_action_and_result}`
13
14 Call counter from `WANObjectCache::getWithSetCallback()`.
15
16 * Type: Counter.
17 * Variable `kClass`: The first part of your cache key.
18 * Variable `result`: One of:
19 * `"hit.good"`,
20 * `"hit.refresh"`,
21 * `"hit.volatile"`,
22 * `"hit.stale"`,
23 * `"miss.busy"` (or `"renew.busy"`, if the `minAsOf` is used),
24 * `"miss.compute"` (or `"renew.busy"`, if the `minAsOf` is used).
25
26 #### `wanobjectcache.{kClass}.regen_set_delay`
27
28 Upon cache miss, this measures the time spent in `WANObjectCache::getWithSetCallback()`,
29 from the start of the method to right after the new value has been computed by the callback.
30
31 This essentially measures the whole method (including retrieval of any old value,
32 validation, any locks for `lockTSE`, and the callbacks), except for the time spent
33 in sending the value to the backend server.
34
35 * Type: Measure (in milliseconds).
36 * Variable `kClass`: The first part of your cache key.
37
38 #### `wanobjectcache.{kClass}.ck_touch.{result}`
39
40 Call counter from `WANObjectCache::touchCheckKey()`.
41
42 * Type: Counter.
43 * Variable `kClass`: The first part of your cache key.
44 * Variable `result`: One of `"ok"` or `"error"`.
45
46 #### `wanobjectcache.{kClass}.ck_reset.{result}`
47
48 Call counter from `WANObjectCache::resetCheckKey()`.
49
50 * Type: Counter.
51 * Variable `kClass`: The first part of your cache key.
52 * Variable `result`: One of `"ok"` or `"error"`.
53
54 #### `wanobjectcache.{kClass}.delete.{result}`
55
56 Call counter from `WANObjectCache::delete()`.
57
58 * Type: Counter.
59 * Variable `kClass`: The first part of your cache key.
60 * Variable `result`: One of `"ok"` or `"error"`.
61
62 #### `wanobjectcache.{kClass}.cooloff_bounce`
63
64 Upon a cache miss, the `WANObjectCache::getWithSetCallback()` method generally
65 recomputes the value from the callback, and stores it for re-use.
66
67 If regenerating the value costs more than a certain threshold of time (e.g. 50ms),
68 then for popular keys it is likely that many web servers will generate and store
69 the value simultaneously when the key is entirely absent from the cache. In this case,
70 the cool-off feature can be used to protect backend cache servers against network
71 congestion. This protection is implemented with a lock and subsequent cool-off period.
72 The winner stores their value, while other web server return their value directly.
73
74 This counter is incremented whenever a new value was regenerated but not stored.
75
76 * Type: Counter.
77 * Variable `kClass`: The first part of your cache key.
78
79 When the regeneration callback is slow, these scenarios may use the cool-off feature:
80
81 * Storing the first interim value for tombstoned keys.
82
83 If a key is currently tombstoned due to a recent `delete()` action, and thus in "hold-off", then
84 the key may not be written to. A mutex lock will let one web server generate the new value and
85 (until the hold-off is over) the generated value will be considered an interim (temporary) value
86 only. Requests that cannot get the lock will use the last stored interim value.
87 If there is no interim value yet, then requests that cannot get the lock may still generate their
88 own value. Here, the cool-off feature is used to decide which requests stores their interim value.
89
90 * Storing the first interim value for stale keys.
91
92 If a key is currently in "hold-off" due to a recent `touchCheckKey()` action, then the key may
93 not be written to. A mutex lock will let one web request generate the new value and (until the
94 hold-off is over) such value will be considered an interim (temporary) value only. Requests that
95 lose the lock, will instead return the last stored interim value, or (if it remained in cache) the
96 stale value preserved from before `touchCheckKey()` was called.
97 If there is no stale value and no interim value yet, then multiple requests may need to
98 generate the value simultaneously. In this case, the cool-off feature is used to decide
99 which requests store their interim value.
100
101 The same logic applies when the callback passed to getWithSetCallback() in the "touchedCallback"
102 parameter starts returning an updated timestamp due to a dependency change.
103
104 * Storing the first value when `lockTSE` is used.
105
106 When `lockTSE` is in use, and no stale value is found on the backend, and no `busyValue`
107 callback is provided, then multiple requests may generate the value simultaneously;
108 the cool-off is used to decide which requests store their interim value.