aboutsummaryrefslogtreecommitdiffstats
path: root/includes/libs/objectcache
Commit message (Collapse)AuthorAgeFilesLines
* objectcache: suppress various PhpUnusedLocalVariableInspection warnings in ↵Aaron Schulz2025-04-042-12/+13
| | | | | | WANObjectCache Change-Id: I9977d80bbbff215b18c9f099f0bef0865a3d1ac5
* objectcache: Fix RestBagOStuff bytes sent statsHannah Okwelum2025-04-041-1/+1
| | | | | | | The current total bytes sent is computed on the response body recieved from the server. What we want is to compute this on the actual request body being sent to the server. Bug: T390815 Change-Id: I7d48a5e08f112329ebc4743a1cbd98d0f7144a69
* objectcache: Improve docs for BagOStuff::ATTR_DURABILITY docsTimo Tijhof2025-03-271-12/+37
| | | | | | | | | | | | | | | | Explain why they exist, how they're used, and what classes they effectively exist to detect. This feature was first added for T141804 to enable detection of CACHE_DB, and skip in ChronologyProtector or WANCache defaults, when constructing Rdbms/LBFactory to avoid recursion. However, that original use case has been replaced with the simpler "isDatabaseId" function. But, two new uses have shown up since then, and these are now documented to explain why the attribute is still useful. Change-Id: If39fcde689a4ea7dd396657fdc1c261d280e5e16
* objectcache: Remove internal StorageAwareness, now unusedTimo Tijhof2025-03-275-105/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update a few remnant references inside the library while at it. * WANObjectCache: Didn't use ATTR/QOS directly, and getQoS test already implemnented as BagOStuff const. Update getQoS() docs to match. * WANObjectCache: Already documented ERR_ as BagOStuff::ERR_. And Codesearch confirms no use of `WANObjectCache::(ERR|ATTR|QOS)`. * MemcachedClient: Switch from referencing one to the other. The class is not directly used outside core, only via BagOStuff. * Implicitly remove unused ATTR_EMULATION by not carrying over. Follows-up: * e8275758fe (I20fde9fa5c) Split IExpiringStore from BagOStuff, and re-use in WANObjectCache. * 74be3a0150 (I4377fc3f53) Move ERR_ from BagOStuff to IExpiringStore. * 69950da666 (Ia862c5111a) Replace IExpiringStore with StorageAwareness. * 59b002b866 (I9885f53f00) Remove StorageAwareness::QOS_LOCALITY_. * ec90b543ab (I8dec3f73fa) Remove StorageAwareness::QOS_EMULATION_SQL. * 62bdd78817 (I5649a29310) Adopt ERR_ in MemcachedClient. * e5a3e36bd1 (I836735b1fe) Mark StorageAwareness as internal. Bug: T353529 Bug: T364652 Change-Id: I1dfde995e29d5264611cf3500d61fe4d8631a7d7
* objectcache: Simplify code in WANObjectCacheAmir Sarabadani2025-03-131-64/+22
| | | | | | | | | - Remove unused argument in private method in ::makeSisterKey() - Turn ::prependRoute() into ::getRouteKey() to DRY - That simplified ::relayVolatilePurge() and ::relayNonVolatilePurge() so much that we merged them to the callers. Change-Id: I9240b747bec511d7f5c4104debfc9b1632360db5
* objectcache: Remove deprecated stuff from WANObjectCacheAmir Sarabadani2025-03-061-18/+0
| | | | Change-Id: If542e6096a73e8a954937c088d619d197f4555bf
* objectcache: Inline small one-off private methods in WANObjectCacheAmir Sarabadani2025-02-201-84/+20
| | | | | | | They are hurting the flow of reading the code. Split should be somewhere else. Change-Id: I5aae6c40362efc1925ff912c924d3fc547b001af
* Merge "libs: Replace call_user_func with dynamic function call"jenkins-bot2025-02-081-1/+1
|\
| * libs: Replace call_user_func with dynamic function callUmherirrender2025-01-311-1/+1
| | | | | | | | | | | | | | | | Use modern php syntax to call a callable. Reduce the stack trace to improve performance and better IDE and static analyzer support Change-Id: I8e563140ac3465ce3b3f8ec5e01bfd493c7269fe
* | Merge "Add prefix option to RedisConnectionPool"jenkins-bot2025-02-042-2/+15
|\ \ | |/ |/|
| * Add prefix option to RedisConnectionPoolRyan Schmidt2025-01-292-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new prefix option to Redis to transparently prefix all get/set operations with a specified prefix. The use case for this is when providing a multitenant Redis/valkey cluster for multiple wikis that are not necessarily part of the same wiki farm and thus should have fully-isolated keyspaces. This patch additionally adjusts the doc comment type for the password field to align with reality. The class was already defaulting password to null, and the Redis connection class itself accepts both a single string as a password as well as an array with 2 elements defining the username and password. Change-Id: I9c39a0a60e01ecc29f76b98ed5f8e4e28802c533
* | WANObjectCache: trace basic operationsChris Danis2025-01-301-1/+79
| | | | | | | | | | | | | | | | | | | | | | | | Follows the instrumentation collected in Iab20f86139fd9388ccd881be28ed324b7f64c533 I'm not sure if including all the keys/checkKeys is useful, or if I should be performing some aggregation or other summary. Perhaps using determineKeyGroupForStats() ? Bug: T340552 Change-Id: I53dd29ad131a2d81312c64bdf68155d48144a364
* | BagOStuff: Update makeKeyInternal to accept/handle nullReedy2025-01-282-6/+7
| | | | | | | | | | | | | | | | Minor doc fixes Bug: T384858 Follows-Up: I358a0356a55dc5f1349c240c41ec406de85942ee Change-Id: Ie62624793d3b2956b821517bb0d31d19e2d5e7c2
* | MemcachedBagOStuff: Null coalescing $componentReedy2025-01-271-1/+1
|/ | | | | | | Upstream callers should probably be fixed too.. Bug: T384858 Change-Id: I358a0356a55dc5f1349c240c41ec406de85942ee
* Tests: assert updates on page lifecycle changesdaniel2025-01-241-2/+2
| | | | | | | | | | | | | | | | | | | | Why: - We want to refactor code that performs page lifecycle changes, such as edit, create, delete, import, etc. - The goal of the refactoring is to apply the observer pattern in order to remove direct dependencies from page related code on code that needs to be notified of the change. - Before we start refactoring, we should cover the current behavior in tests. What - Rename and clarify semantics of spy traits introduced earlier. - Add coverage for talk page notifications - Add coverage for resource loader module cache updates - Fix dirty entries in Title instance cache after deletion Bug: T378936 Change-Id: If06e2aa5bda84dfbee3278bf4a8d16064b6effc8
* Storage,MessageCache: Reference TTL constants from BagOStuffTimo Tijhof2025-01-201-0/+1
| | | | | | | | | | | | | Mark `ExpirationAwareness` as internal, as it is effectively a private trait for the benefit of de-duplication between MapCacheLRU, BagOStuff, and WANObjectCache APIs. Callers should reference constants from the object ($cache::TTL_DAY) or type (BagOStuff/WANObjectCache) that their code is interfacing with. Fix a handful of cases that didn't do this. Bug: T353529 Change-Id: Ic46e09c848e69db3d22219d2231274c81c0cb275
* Remove trivial 1-line PHPDocs that just repeat the codethiemowmde2025-01-161-3/+0
| | | | | | | | | | | | | I assume these are all either auto-generated by an IDE or the language-level type declarations have been added later. In any case the comments don't add any new information to what the code already says. This is just extra clutter that makes the code harder to read, I would argue. There are many, many more comments like this. In this patch I intentionally focus on the most trivial 1-line comments. Change-Id: Ia294bf4ce0d8a77036842fe25884bc175c2b0e7d
* objectcache: Move RedisConn files out of utils/ to match classTimo Tijhof2025-01-032-0/+0
| | | | | | | | | | | | This class was namespaced in commit 72338de32b, but its location did not match what you'd expect based on its namespace. For consistency and to ease discovery, move it into the flat `objectcache/` directory. Bug: T364652 Bug: T353529 Change-Id: I3d77cb22560eeec7d77a2a818583527efd2176ce
* objectcache: Tag SerializedValueContainer as `@internal`Timo Tijhof2025-01-032-5/+2
| | | | | | | | | | | | | | | | | There is no reason for code outside the BagOStuff component to use this class. It is used solely for encoding, detecting, and decoding internal value wrappers. Any value passed to or returned by BagOStuff methods does not involve this class. Between MW 1.34 and 1.43 this class had more public methods, which have since been removed. As an internal class, move this freely into the flat list of objectcache/ classes. Bug: T353529 Bug: T364652 Change-Id: I22178bdaf6c9762a32e7428d3a286583ca99bfcf
* objectcache: Move internal StorageAwareness to ObjectCache namespaceTimo Tijhof2025-01-034-4/+2
| | | | | | | | | | | | | | | | | | * The LightweightObjectStore namespace was experimentally adopted for two classes in 2020 with change Ia862c5111a3daf10a34fc78163301629, however in 2024 when we namespaced the BagOStuff component as a whole, we went with ObjectCache namespace in change Ie01962517e. * The StorageAwareness class is internal since I836735b1fec8dfd, so it can be freely renamed. * Similar to I836735b1fec8dfd, further reduce direct use of it, keeping it only as effectively an internal trait for adding a consistent set of constants to 3 classes (Bag, Wan, MemcClient). Bug: T353529 Bug: T364652 Change-Id: Ib10db39a91274e84a51a2eead94560b8d9137019
* objectcache: Remove WANObjectCache doc about cool-off sister keysDerick Alangi2024-11-211-2/+0
| | | | | | | | In Ie3a2215d3325fe72 (f83f75d), this feature was removed but seems like this bit was left out. This patch removes the documentation about this key type. Change-Id: Id4cac80c932c7f511eec6380e4dd68440cbc4c14
* Merge "Use foreach+array_map for iterating over two arrays at the same time"jenkins-bot2024-11-151-6/+4
|\
| * Use foreach+array_map for iterating over two arrays at the same timeBartosz Dziewoński2024-10-191-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | To iterate over the corresponding values from two or more arrays at the same time, one can use this pattern: foreach( array_map( null, $as, $bs ) as [ $a, $b ] ) { ... } Use it instead of iterating manually with a while loop and the primitives reset()/current()/next() in a couple of cases. I find it easier to read, and it's definitely less error-prone. Change-Id: Iaf1fcf7ed7591b492160e99c2f4ba4be54de2e1a
* | objectcache: Remove docs about RedisConnectionPool configurable sizeTimo Tijhof2024-10-282-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There exists no option matching this description. The class was created in Feb 2013 with Ie72536240e (03833b54e8), which initially included a `poolSize` option that matches this description. This was removed the next month in March 2013, with I6ea53378c9 (646051d36d). While at it, fix file headers and ingroup doc annotations > Add missing `ingroup` to class blocks (and remove from file blocks) > as otherwise the file is indexed twice (e.g. in Doxygen) which makes > navigation on doc.wikimedia.org rather messy. > > Remove duplicate descriptions from file blocks in favour of class > doc blocks. This reduces needless duplication and avoids incorrect > or outdated copies emerging over time, and helps make file headers > more consistently (visually) ignorable. > > Ref https://gerrit.wikimedia.org/r/q/message:ingroup+is:merged+owner:Krinkle+branch:master Change-Id: I285122054c8848d0fa700aa323ff813d5f0c4690
* | objectcache: Move RedisConnRef.php to /libs/objectcache/Timo Tijhof2024-10-283-2/+739
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because: * component description on mw:Maintainers, * Phab description and who triages/maintains the code, * primary usage of these classes, * consistency with MemcachedClient.php. Follows-up I7a874e1ee1 (2144fef6d1), which namespaced these under a new Wikimedia\Redis namespace instead based on the prior directory naming. Bug: T364652 Bug: T353529 Change-Id: I4c6a349afcc4039bec27413af9511639f8c0c4b0
* | Use ++ and -- rather than += 1 and -= 1Reedy2024-10-171-1/+1
| | | | | | | | Change-Id: I27b9a19ab952ede1267921bd042af0fe1c89e228
* | Use explicit nullable type on parameter argumentsUmherirrender2024-10-165-11/+11
|/ | | | | | | | | | | Implicitly marking parameter $... as nullable is deprecated in php8.4, the explicit nullable type must be used instead Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a Break one long line in SpecialPage.php Bug: T376276 Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
* Add namespace to remaining parts of Wikimedia\Mime and Wikimedia\StatsJames D. Forrester2024-09-271-1/+1
| | | | | Bug: T353458 Change-Id: If0137003ab625017d322d57870448a02569668c3
* Add namespace to remaining parts of Wikimedia\ObjectCacheJames D. Forrester2024-09-273-4/+20
| | | | | Bug: T353458 Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
* Add namespace to Wikimedia\Redis libsJames D. Forrester2024-09-271-2/+2
| | | | | Bug: T353458 Change-Id: I7a874e1ee1d41a75e34b8a6b6f4d065b5b812c43
* objectcache: Fix WANObjectCache docs to clean some minor typosDerick Alangi2024-09-231-5/+5
| | | | Change-Id: I71d798513fb5a28717279e1bbc33b3199ea05346
* Merge "objectcache: Remove `wanobjectcache.$keygroup.regen_set_delay` metric"jenkins-bot2024-09-202-26/+2
|\
| * objectcache: Remove `wanobjectcache.$keygroup.regen_set_delay` metricTimo Tijhof2024-09-182-26/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduced in 2019 with I053a73b40d (97e0939082) as part of an optimization effort around spikes of set operations for the same keys (T203786). This has since been mitigated in other ways, with the related cool-off bounce feature removed in 2023 with Ie3a2215d33 (T321634, f83f75d3e6). As it stands, we have: * getwithset_seconds{result=hit} which effectively measures the typical memcached-get latency. * getwithset_seconds{result=miss} which effectively measures memcached-get + regen callback + memcached-set. * regen_seconds which effectively measures the regen callback. Which seems sufficient. We can also eyeball `miss - get - regen` to gauge the latency of the "set" operation, but we don't have a need to measure that precisely for every memc call in production, idem for the "get + regen" subset that regen_set_delay was measuring. Change-Id: I1c59466f0407f6b980fd04a64a7ab2e3f25c5b0d
* | Remove unchecked exception annotationsAdam Wight2024-09-173-4/+0
|/ | | | | | | | | | | | | | | Callers should not catch an unchecked exception, so it doesn't belong in a function signature. Unchecked exceptions indicate a coding error, which by definition the code will not be able to handle correctly. If any of these exceptions were supposed to be in response to an edge case, user input, or initial conditions, then they should be changed to a runtime error. If the exception class cannot be changed, then the annotation should include a comment explaining its purpose and prognosis. Bug: T240672 Change-Id: I2e640b9737cb68090a8e1cb70067d1b74037d647
* objectcache: Tag StorageAwareness as `@internal`Timo Tijhof2024-09-151-1/+1
| | | | | | | | | | | | | Only has 1 use outside libs/objectcache, recently introduced in the ApiFeatureUsage extension, fixed in Ied085eb5. The uses of it already documented against BagOStuff, e.g. getLastError() returns a BagOStuff::ERR_ constant, not StorageAwareness. To simplify the API and reduce clutter and improve cohesion, move this gradually back in. Change-Id: I836735b1fec8dfdcb82804cd5a698047d6a6a7c7
* objectcache: Improve overall BagOStuff class docsTimo Tijhof2024-09-1116-81/+129
| | | | | | | | | | | | | | | | | Fix file doc blocks while at it. > Remove duplicate description from file block in favour of class doc. > This reduces needless duplication and is often incorrect or outdated, > and helps make file headers more consistently (visually) ignorable. > > Add missing `ingroup` to class doc (and remove any from file doc) > as otherwise the file is indexed twice (e.g. in Doxygen) which makes > navigation on doc.wikimedia.org rather messy. > > Ref https://gerrit.wikimedia.org/r/q/message:ingroup+is:merged+owner:Krinkle+branch:master Bug: T364652 Change-Id: Icc36566da1c7190b0f4269719f34d3d6a83026c1
* objectcache: Migrate WANObjectCache metrics to StatsLibDerick Alangi2024-09-101-35/+90
| | | | | | | | | | | | | | | | | | | This patch begins migrating the WANObjectCache metrics from graphite to prometheus. This class can be constructed directly and parameter options (which might include a stats collector object) passed, so we need a way to detect the incorrect case and warn accordingly. Since this is used by extensions, and we want to support only the new StatsFactory option. We need a way to track and warn places where the old stats collector is still in use and also put in place a mechanism so new code doesn't use the old stats collector. So, constructing a WANObjectCache object with an IBufferingStatsDataFactory stats collector is deprecated in this patch in favor of the new collector. Callers are responsible for fixing usage to StatsFactory. Bug: T359257 Change-Id: If1162f69997b1b914fb9e02dad7d7ae1540d2d01
* Merge "objectcache: Remove WinCache support"jenkins-bot2024-09-061-175/+0
|\
| * objectcache: Remove WinCache supportMáté Szabó2024-09-051-175/+0
| | | | | | | | | | | | | | | | | | | | | | | | WinCache is an APCu equivalent for use with Microsoft IIS, but in recent years has been unmaintained and lacks support for PHP 8 and newer.[1] So, remove support for it as MediaWiki will be raising the minimum supported PHP version to 8.1. [1] https://www.php.net/manual/en/install.windows.recommended.php Bug: T365691 Change-Id: I4d2dc01a9119bb1f858132f0146b894750c1e86d
* | Merge "objectcache: Improve WANCache docs"jenkins-bot2024-09-051-30/+61
|\ \
| * | objectcache: Improve WANCache docsTimo Tijhof2024-09-051-30/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Make text more accessible with simpler terms. * Reduce linking to get()/set() to discourage these, and swap prominence of validation B and C. * Add examples for why/when you'd use certain validation strategies. * Mention "WANCache" for improved search on doc.wikimedia.org. * Document pronunciation. * Cross-link to https://wikitech.wikimedia.org/wiki/Memcached_for_MediaWiki Test Plan: * php maintenance/mwdocgen.php --file includes/libs/objectcache/ * http://localhost:4000/docs/html/classWANObjectCache.html#details Bug: T364652 Change-Id: I12b05e03b0fc46ad3d8e625434901bb54451fbeb
* | | Merge "objectcache: Remove ReplicatedBagOStuff, deprecated since 1.42"jenkins-bot2024-09-041-308/+0
|\ \ \ | | |/ | |/|
| * | objectcache: Remove ReplicatedBagOStuff, deprecated since 1.42Ebrahim Byagowi2024-09-041-308/+0
| |/ | | | | | | | | Bug: T352481 Change-Id: I4e1ee5680b7ba0207dfe30a1208db35eca07e218
* / build: Use inline ignore for Generic.CodeAnalysis.AssignmentInConditionUmherirrender2024-09-012-0/+2
|/ | | | | | | | | | | Avoid that new code contains this pattern. Depends-On: I7a9b5c89129fe4b555d03861f2c3ce3e9e2b2446 Depends-On: Ic2bcc7eeb16d3333dcd019bd209bd7fde843dab9 Depends-On: If20eddd8376ae2e8e29c4e56cd51f7b8eb6642b0 Depends-On: I3414f7e17f4bcb801857bc986bae8eb97aa2bfb8 Depends-On: I38b2729418e8389c681c6cd84858f5e5ed25bd3e Change-Id: I7cfd2e027edd327cf8be6471e348c137fefacda0
* Use variable-length argument lists instead of func_get_args()Bartosz Dziewoński2024-08-161-4/+2
| | | | | | (plus some other tweaks to code using array unpacking weirdly) Change-Id: I76a280548952ee5144ca7e75e00d530ad55c22d7
* objectcache: Consolidate WRITE_PRUNE_SEGMENTS into WRITE_ALLOW_SEGMENTSTimo Tijhof2024-08-092-45/+18
| | | | | | | | | | | | | | | | | | | Instead of making the caller responsible for knowing what we do internally at each step, rebrand WRITE_ALLOW_SEGMENTS as generally "do stuff for segments", not only creating them, but also deleting them. * Easier to find and verify correct usage. * Easier to understand parity between set() and delete(). * Documentation for deleteMulti() already said this, by mistake. * Reduce amount of required knowledge. There is only 1 usage in Codesearch Everywhere (in PageEditStash here in core), with no known usage anywhere else. Hypothetically, if it were used, this commit keeps compat by aliasing WRITE_PRUNE_SEGMENTS to WRITE_ALLOW_SEGMENTS. Change-Id: Iea10b23f06243814c35ccd02a4a878cdc1195c76
* objectcache: fix spelling typo in WANObjectCache commentsAaron Schulz2024-07-301-1/+1
| | | | Change-Id: I7a668cdd95297991a4f82c3a07e94ddc1b495c80
* objectcache: Hard deprecated `::clearLastError()` methodsDerick Alangi2024-07-182-2/+4
| | | | | | | | | | | | | | | | | | | BagOStuff::watchErrors() returns a token that can be used with the BagOStuff::getLastError() method to get the last error registry. Use this instead of deprecated clearLastError(). This new style for clearing last errors was introduced in 2021, I281817a85602967c0ec2bdd23a5d8be101680b64 (I281817a85602967) as it is more robust due to its support for allowing nested callers. An outside BoS instance might want to watch the errors returned by multiple internal BoS instances and with the use of watch point tokens, this is possible. This patch hard deprecates BagOStuff::clearLastError() and WANObjectCache::clearLastError(). Change-Id: I9b7a77bae8c0d5cc0235f0894a92f8e38628826d
* Add namespace to the root classes of ObjectCacheEbrahim Byagowi2024-07-1016-12/+244
| | | | | | | | | And deprecated aliases for the the no namespaced classes. ReplicatedBagOStuff that already is deprecated isn't moved. Bug: T353458 Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
* objectcache: Deprecate unused methods in BagOStuff.phpDerick Alangi2024-07-082-0/+12
| | | | | | | | | | | | | | | These methods: getSegmentationSize() and getSegmentedValueMaxSize() in both the BagOStuff.php and MediumSpecificBagOStuff classes seem unused for a while now. Codesearch shows that we have no callers of both the parent and child class overrides. Since these are public interfaces, they'll have to go through the deprecation process. Introduced in b09b3980f991b (I0667a02612526d8ddfd91d5) and later in 2021, usage was all removed in 942f708b61d8d7 (I5c4bd74379bc45). Change-Id: Ie529841e673abc7b68f870539dbb23a34a292c89