Commit graph

23 commits

Author SHA1 Message Date
Aaron Schulz
69ad84cf36 Make MapCacheLRU::get() accept a default value and improve $maxAge default
Change-Id: If562e1745ffed37b0f1ed5382a5a397fc68aac8e
2019-07-10 22:27:51 +00:00
Aaron Schulz
b4da5a8181 Improve MapCacheLRU error message
Bug: T201893
Change-Id: I74ef2cf31d83186f68e676da1b80c4c44ca28d69
2018-08-13 22:52:22 -07:00
jenkins-bot
dccec12761 Merge "Make MapCacheLRU throw errors for bad $field arguments" 2018-08-14 01:17:17 +00:00
Aaron Schulz
39a63a3c16 Make MapCacheLRU throw errors for bad $field arguments
Change-Id: Ibde33e0ff671d3428b73c66766478f58763726e1
2018-08-14 00:41:33 +00:00
Niklas Laxström
3466da043d MapCacheLRU: Fix a typo in a comment
Change-Id: I573623f219f83528ea46ee31d656fce935b3b431
2018-08-08 09:31:54 +02:00
Aaron Schulz
031a4c747e Add $maxAge parameter to MapCacheLRU get() and getField() methods
Change-Id: I2dee1ad3a5b4f2ef8c182e3466812777a9a9cf7f
2018-07-18 18:08:53 +00:00
Aaron Schulz
9d35884e82 Use func_num_args() in MapCacheLRU::clear() for sanity
Change-Id: Ie11e18a342db0176271e4d08f56a99b0e3caacbe
2018-07-13 15:15:52 +01:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Aaron Schulz
1f2b2f3f8d Add key expiration and map resizing support to MapCacheLRU
Also implement Serializable in to add stability to anything that
uses naïve serialization (such as for persistent caching).

Change-Id: I03ba654ffd80ba027d47d5d7583abfe48d52818d
2018-06-28 05:53:42 +00:00
Aaron Schulz
01307b2cc9 Allow two-queue style insertion in MapCacheLRU
Change-Id: I1cd98ea8965b51e43371efd990fb9302bb507928
2017-09-25 21:28:38 +00:00
Aaron Schulz
894dffc67f Remove use of MWException in MapCacheLRU
Change-Id: I830555ffcb1b50bdc54e552daa469e2c5e00611d
2017-09-22 17:38:46 +02:00
Chad Horohoe
70c2223843 MapCacheLRU: Properly handle bogus cache keys
They can only be strings or integers. Anything else is wrong. We
should be throwing exceptions here so developers find this early
when running tests and manual testing.

Exceptions (instead of warnings) allow us to get a full useful
stacktrace.

Change-Id: I823ce33523283509c14a05f816f261d6b400e243
2016-12-06 12:42:49 -08:00
Kunal Mehta
a41f187511 MapCacheLRU: Support null values in getWithSetCallback()
The rest of this class supports having a key with a null value by using
array_key_exists() instead of isset(). So Use $this->has() in
getWithSetCallback() so a null value is still identified as set.

Change-Id: Ida74a6f7e284e98f9a7d76d97312ebe2ee343f10
2016-09-12 21:45:51 -07:00
Timo Tijhof
f245845056 Revision: Simplify loadText() with nested getWithSetCallback
Check the MapCacheLRU::get() return value properly for misses
this time.

This reverts commit 1f022240c7.

Change-Id: Ic95b79ad8d7d7c788f406d45c0e9bedeeb8d220b
2016-09-07 14:03:01 -07:00
Mattflaschen
1f022240c7 Revert "Revision: Simplify loadText() with nested getWithSetCallback"
This reverts commit aa0f6ead34.

Change-Id: I285ada2e86f014b93c7e7946f10d2dc84375fcff
2016-09-07 20:34:58 +00:00
Timo Tijhof
aa0f6ead34 Revision: Simplify loadText() with nested getWithSetCallback
The logic was a bit hard to follow as there were two layers of
caching and a conditional (expiry being set).

* Move fetch logic for revision text to a private method.
* Call directly when cache is disabled.
* Simplify cache has/get/set by using getWithSetCallback.

Change-Id: Icd74cd8e944266c20dc7c5cb25f56300636dce1e
2016-09-07 18:44:04 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Timo Tijhof
7f01755fdf CacheLRU: Simplify >0 assertion and remove verbose inline comment
* Consistently refer to above zero as '> 0', not ">= 1" or "not <= 0".

* Remove superfluous comment that say what ping() does.

Change-Id: I25d276faa555e02feb99e656eb9cb7071f8205c0
2015-10-20 03:19:17 +01:00
daniel
7081228214 Start using the Assert helper class for checking parameters.
This introduces https://github.com/wmde/Assert as a dependency,
as discussed in the RFC T91071.

This change uses assertions to check some parameters in some places,
to showcase the main intended use case for assertions in MediaWiki.

Bug: T91071
Change-Id: I93ac39b7c146f10532e37b51d973b59b9c424b2f
2015-05-11 17:54:07 +00:00
Alex Monk
156bcbec81 Mostly revert "Verify parameter for MapCacheLRU::has() can be passed to array_key_exists()"
This broke a few things, and the debug line was basically pointless.

Instead, continue to only throw an exception if $text is an object, but only
warn if it's otherwise not a string.

This reverts commit 372ded2fea.

Change-Id: I060da9191cdbd00c4873caba875bfb77c917bcd7
2015-04-07 02:08:11 +00:00
Mark A. Hershberger
372ded2fea Verify parameter for MapCacheLRU::has() can be passed to array_key_exists()
This prevents warnings from PHP from array_key_exists().

Also make sure Title::newFromText throws an exception before it can trigger this.

Bug: T76305
Change-Id: I2b36b7a3b96b37e29fe06f69c13a185b3ec592a7
2015-03-23 15:26:59 -07:00
Aaron Schulz
6417abb728 Added MapCacheLRU::getAllKeys() method
Change-Id: Idc9155bb55d37b083a6c1124721b74d4910ccec5
2014-12-25 14:02:50 -08:00
Aaron Schulz
93d2167ca6 Moved MapCacheLRU to libs/
Change-Id: Icb820787afe7298dd3124f5168d3efff19e53ab6
2014-11-10 22:51:29 +00:00
Renamed from includes/cache/MapCacheLRU.php (Browse further)